Clean up Docker images, containers, volumes, networks and build cache

Task: remove everything related to Docker and cleanup

Solution:

sudo docker system prune

If you want to remove any stopped containers and all unused images, not just dangling images use it with “-a” option:

sudo docker system prune -a

Why: after playing with Docker and Docker Compose at some point you may have tons of unused images and containers which occupy disk space. I do not like keeping unnecessary files on my system 🙂

Links:
How To Remove Docker Images, Containers, and Volumes (DigitalOcean)
Docker Pruning (official docs)

Leave a Reply