Docker 查看退出容器的日志 [英] Docker look at the log of an exited container
本文介绍了Docker 查看退出容器的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以查看退出的容器的日志吗?
Is there any way I can see the log of a container that has exited?
我可以使用 docker ps -a
获取退出容器的容器 ID,但我想知道它运行时发生了什么.
I can get the container id of the exited container using docker ps -a
but I want to know what happened when it was running.
推荐答案
使用 docker 日志
.它也适用于停止的容器并捕获容器主进程的整个 STDOUT 和 STDERR 流:
Use docker logs
. It also works for stopped containers and captures the entire STDOUT and STDERR streams of the container's main process:
$ docker run -d --name test debian echo "Hello World"
02a279c37d5533ecde76976d7f9d1ca986b5e3ec03fac31a38e3dbed5ea65def
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
49daa9d41a24 debian "echo test" 2 minutes ago Exited (0) 2 minutes ago test
$ docker logs -t test
2016-04-16T15:47:58.988748693Z Hello World
这篇关于Docker 查看退出容器的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文