How to Kill All Docker Containers?

Quick tip to immediately terminate all running Docker containers

You can immediately stop/kill all running Docker containers by using the following command:

docker kill $(docker container ls -q)

This command does the following:

  • docker container ls -q returns the list of ids of all running containers;
  • docker kill immediately stops/kills the containers (by sending the SIGKILL signal to the main process inside the container).

You can also use docker ps -q instead of docker container ls -q. However, the latter is the newer syntax and is more readable than the former.

You can also choose to gracefully stop all running containers by using the docker stop command instead of docker kill. Please note though that there are some subtle differences between the two commands.

Hope you found this post useful. It was published . Please show your love and support by sharing this post.