Docker How To Stop All Containers
Often times, after a lot of testing, your system can get a bit messy. Cleaning up docker containers one by one can be tedious. Fortunately, this can be done all at once with a single combined command.
To stop all docker containers use this command:
docker stop $(docker ps -a -q)
To remove/delete all containers use this command:
docker rm $(docker ps -a -q)
This command shows the id for every docker container on a system:
docker ps -a -q
-a | all containers, even stopped |
-q | only show id, works as a parameter |
You can also remove all images with the following:
docker rmi $( docker images -q )