Finding a string in docker logs of container

前端 未结 8 1053
南方客
南方客 2021-01-30 01:21

What is the best way to find a specific string in the logs of a docker container? Let\'s say I want to see all requests, that are made in the \"nginx\" docker image that came fr

8条回答
  •  后悔当初
    2021-01-30 02:06

    First, use this command ( b1e3c456f07f is the container id ):

    docker inspect --format='{{.LogPath}}' b1e3c456f07f
    

    The result will be something like this:

    /var/lib/docker/containers/b1e3c456f07f2cb3ae79381ada33a034041a10f65174f52bc1792110b36fb767/b1e3c456f07f2cb3ae79381ada33a034041a10f65174f52bc1792110b36fb767-json.log
    

    Second, use this command ( you can use vim if you like ):

    nano /var/lib/docker/containers/b1e3c456f07f2cb3ae79381ada33a034041a10f65174f52bc1792110b36fb767/b1e3c456f07f2cb3ae79381ada33a034041a10f65174f52bc1792110b36fb767-json.log
    

提交回复
热议问题