What is “dead” status of a container?

2019-07-27 01:42发布

https://docs.docker.com/engine/reference/commandline/ps/ says

status One of created, restarting, running, removing, paused, exited, or dead

What does "dead" status mean for a container?

标签: docker
1条回答
Rolldiameter
2楼-- · 2019-07-27 02:13

Just going by the documentation I could find:

"dead" is used for a "defunct" container; for example, a container that you wanted to remove but was only partially removed because resources were kept busy by an external process. Dead containers cannot be (re)started, only removed. You can manually attempt to remove a dead container (if the problem causing it to not be removed in the first attempt failed), and the daemon will automatically attempt to remove dead containers when it's restarted.

From Docker maintainer Sebastiaan van Stijn, https://github.com/docker/cli/issues/502#issuecomment-330361748 That is a pretty authoritative source on the matter, so it does look like the Stackoverflow answer you linked to was correct.

Does "dead" mean that the container has been removed by docker rm ?

docker rm was performed, but only partially succeeded, so it's still there, in that dead state.

And yes, they would show up in ps --all:

While reviewing the output of docker ps -a you may have seen both dead and exited statuses for containers. https://success.docker.com/article/what-is-the-difference-between-dead-and-exited-containers

If a container exits before completion due to error, what is its status?

Its status is "Exited" with the error code it returned, e.g. "Exited (1) 10 seconds ago". https://success.docker.com/article/what-is-the-difference-between-dead-and-exited-containers

Does "exited" mean "A container that ran and completed"?

Yes, the status includes the exit status code of the main process.

查看更多
登录 后发表回答