Commands to clear Docker
Here are a few easy ways to clear docker images and containers:
Stop all containers:
docker ps -aq | xargs docker stop
Remove all containers:
docker ps -aq | xargs docker rm
Remove all images:
docker images -aq | xargs docker rmi
Remove all networks:
docker network ls -q | xargs docker network rm
Remove all dangling images
(https://docs.docker.com/engine/reference/commandline/image_prune/):
docker image prune
Remove all volumes:
docker volume ls -q | xargs docker volume rm
Remove all stopped containers, unused networks, dangling images, and build cache:
docker system prune