Subject: [Docker Forums] [General Discussions] Docker stop conatiners

Let me see if I get this right. You are doing:

1. `docker stop my_container`
1. `docker container prune`

What happens when you do the `docker stop`command is that docker sends a SIGTERM to the root process (PID 1) in your container and ask is nicely to shut down. And then it waits for 10 seconds and if the container hasn't exited by then, it sends a SIGKILL to the kernel. That is the normal way to do it.

However, I have noticed that some applications, like Nginx, don't react gracefully on the SIGTERM (it does a fast shutdown) and looking in the documentation ( shows that it wants a SIGQUIT to do it gracefully.

But even when doing a fast shutdown, 10 seconds has not been enough in some cases. What I have noticed in these cases is that the volume used by the container gets in a read only state or sometimes just goes away. This leaves the container in a defunct state and marks it as dead.

Another case of mine was when I used a shared nfs for storing a Jenkins data and when updating to a new Jenkins started the new one before I shut down the old one. That made the old one grumpy and left it in a dead state since it lost the write privileges.

I think (qualified guess without looking in the docker code) that lost or read only volumes is one of the most common causes for a dead container.