简体   繁体   English

我怎么知道为什么 Docker 容器停止了?

[英]How can I know why a Docker container stopped?

I have a Docker container that contains a JVM process.我有一个包含 JVM 进程的 Docker 容器。 When the process ends the container completes and stops.当进程结束时,容器完成并停止。

While thankfully rare, my JVM can go legs-up suddenly with a hard-failure, eg OutOfMemoryError .虽然非常罕见,但我的 JVM 可能会突然出现硬故障,例如OutOfMemoryError When this happens my container just stops, like a normal JVM exit.发生这种情况时,我的容器会停止,就像正常的 JVM 退出一样。

I can have distributed logging, etc., for normal JVM logging, but in this hard-fail case I want to know the JVM's dying words, which are typically uttered on stderr.对于普通的 JVM 日志记录,我可以使用分布式日志记录等,但在这种硬故障情况下,我想知道 JVM 的临终遗言,这通常是在 stderr 上说的。

Is there a way to know why my container stopped, look around in logs, stderr, or something along these lines?有没有办法知道为什么我的容器停止了,在日志、标准错误或类似的东西中环顾四周?

You can run the docker logs [ContainerName] or docker logs [ContainerID] command even on stopped containers.即使在已停止的容器上,您也可以运行docker logs [ContainerName]docker logs [ContainerID]命令。 You can see them with docker ps -a .你可以用docker ps -a看到它们。

Source: the comment of Usman Ismail above: this is just a way to convert his comment into a proper answer.来源:以上Usman Ismail 的评论:这只是将他的评论转换为正确答案的一种方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM