how to redirect docker logs to a single file?

2019-03-08 07:20发布

I want to redirect all the logs of my docker container to single log file to analyse them. I tried

docker logs container > /tmp/stdout.log 2>/tmp/stderr.log

but this gives log in two different file. I already tried

docker logs container > /tmp/stdout.log

but it did not work.

7条回答
看我几分像从前
2楼-- · 2019-03-08 07:50

How about this option:

docker logs containername >& logs/myFile.log

It will not redirect logs which was asked for in the question, but copy them once to a specific file.

查看更多
登录 后发表回答