Docker Frequently Asked Questions and Answers
1) How to stop all docker containers?
docker kill $(docker ps -q)
2) How to stop docker containers and remove them?
docker rm $(docker ps -a -q)
3) How to remove all Docker Images?
docker rmi $(docker images -q)
4) Remove all exited containers
List: docker ps -a -f status=exited
Remove: docker rm $(docker ps -a -f status=exited -q)
5) Remove containers using more than one filter
List: docker ps -a -f status=exited -f status=created
Remove: docker rm $(docker ps -a -f status=exited -f status=created -q)
6) Remove containers according to a pattern
List: docker ps -a | grep “pattern”
Remove: docker ps -a | grep “pattern” | awk ‘{print $1}’ | xargs docker rm
7) Remove one or more specific volumes
List: docker volume ls
Remove: docker volume rm volume_name
8) Remove dangling volumes
List: docker volume ls -f dangling=true
Remove: docker volume prune
9) Remove a container and its volume
docker rm -v container_name