banjocode How To Stop and Remove All Docker Containers

How To Stop and Remove All Docker Containers

Sometimes you start a lot of containers and the same time, this is a simple way to stop and delete them all.

1 min read

Select all Docker containers

When stopping/removing all containers, you have to select them within a stop or rm command.

${docker container ls -aq}
  • ls - list all
  • a - include all, (not just running)
  • q - quiet, only display numeric IDs

Stop all Docker containers

We need to use the stop command in combination with the select command above.

docker container stop $(docker container ls -aq)

Remove all Docker containers

Same as above, we need to use the rm command in combination with the select command.

docker container rm $(docker container ls -aq)