What Does the "docker stop" Command Do?

When you use the docker stop command, it attempts a graceful shutdown of the specified container(s). It does so by sending a SIGTERM signal to the main process inside the container. If the container does not comply or complete the shutdown within a grace period (which is 10 seconds by default), then a SIGKILL signal is sent to immediately stop/kill the container.

The grace period timeout is configurable via the --time (or -t shorthand) option. For example, you can allow a graceful shutdown period of 60 seconds in the following way:

docker stop container_name -t 60

Please note that docker stop <container_name> command is synonymous to the new docker container stop <container_name> command. While both work, the latter/newer syntax was introduced to make the commands more verbose, so that the commands are more obvious in what they do.


This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.