Finding a string in docker logs of container

前端 未结 8 1151
南方客
南方客 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:02

    To follow up on the comments and clarify this for anyone else hitting this issue. Here is the simplest way I can see to search an nginx container log.

    docker logs nginx > stdout.log 2>stderr.log
    cat stdout.log | grep "127."
    

    IMO its kinda messy because you need to create and delete these potentially very large files. Hopefully we'll get some tooling to make it a bit more convenient.

提交回复
热议问题