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.
解决方案
No need to redirect logs.
Docker by default store logs to one log file. To check log file path run command:
docker inspect --format='{{.LogPath}}' containername
/var/lib/docker/containers/f844a7b45ca5a9589ffaa1a5bd8dea0f4e79f0e2ff639c1d010d96afb4b53334/f844a7b45ca5a9589ffaa1a5bd8dea0f4e79f0e2ff639c1d010d96afb4b53334-json.log
Open that log file and analyse.
if you redirect logs then you will only get logs before redirection. you will not be able to see live logs.