Docker: Stop Container

The docker stop command stops running Docker containers.

To stop a container it sends the SIGTERM signal to the main process inside a Docker container requesting it to terminate.

If the main process inside a container is not terminated after a grace period, the docker stop command sends the SIGKILL signal to cause it to terminate immediately.

In this post i am showing an example of how to stop a Docker container and also how to stop all running Docker containers.

Cool Tip: Clean up a Docker host by removing unused Docker containers! Read More →

How To Stop A Docker Container

Use the docker ps command to list running containers and find out the name or ID of a container to stop:

$ docker ps
72ca2488b353  my_image          X hours ago  Up X hours         my_container

Stop a Docker container using the docker stop command:

$ docker stop 72ca2488b353

To stop all containers, run:

$ docker stop $(docker ps -a -q)

Leave a Reply