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.


Select all Docker containers

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

${docker container ls -aq}

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)