Skip to main content

1. Clear the Build Cache

When you build images, Docker keeps layers cached to speed up future builds. To clear just that cache:
docker builder prune
To remove all build cache (even from unused builders):
docker builder prune -a
You’ll be prompted for confirmation — add -f to skip it:
docker builder prune -a -f

2. Remove Unused Data (Safe Global Cleanup)

This removes:
  • stopped containers
  • unused networks
  • dangling images
  • build cache
Run:
docker system prune
For a more aggressive cleanup (includes unused images and volumes):
docker system prune -a --volumes
Be careful — this deletes everything not actively in use by a running container.

3. Remove All Containers, Images, and Volumes

If you want a total reset:
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi -f $(docker images -q)
docker volume rm $(docker volume ls -q)

4. Check Disk Usage Before/After

See what’s taking space:
docker system df

Common cleanup combo (safe and effective)

docker system prune -a --volumes -f
docker builder prune -a -f