The application that I run in a container sends its logs to stdout and this can't be reconfigured. I need these logs to be written to a file to keep them. Is there a way to automatically redirect logs from stdout of a container to a file as soon as the container starts? (I know about "docker logs" command, but it has to be controlled manually and it is no good if a container stops before logs are saved this way.) Thanks in advance.
答案 0 :(得分:0)
使用entrypoint
和stdout
重定向到卷装载来修改stderr
。
command > /volumemount/out 2>&1
现在,所有以前到达容器stdout
的docker日志都将进入主机共享卷。 https://askubuntu.com/questions/625224/how-to-redirect-stderr-to-a-file/625230