If you work with Docker on a daily basis — you’ve probably seen it happen:
Everything runs smoothly, your builds succeed, containers are up…
And then suddenly — “No space left on device” or your computer slows down for no reason.
The truth? It’s not Docker’s fault — it’s yours 😉
Every time you run builds, create containers, or pull new images,
Docker keeps everything on your local disk:
Old images
Stopped containers
Unused volumes
Build cache layers
And it all piles up — fast.
How to Clean Up Docker?
Full Cleanup (Deletes Everything!)
docker system prune -a --volumes
What it does:
- Removes all stopped containers
- Removes all unused images
- Removes all unused volumes
- Clears build cache
💡 Tip: Add --dry-run first to preview what will be deleted.
Gentle Cleanup (Safe for Daily Use)
docker system prune
What it does:
- Removes stopped containers, dangling images, and unused networks
- Does not delete volumes
- Safe to run regularly
Delete Images Only
docker image prune -a
Removes all images not currently used by any container.
Keeps your running containers intact.
Delete Volumes Only
docker volume prune
Cleans up volumes that aren’t connected to any running container.
Great for freeing up old persistent storage.
Delete Build Cache Only
docker builder prune
Removes build cache layers that accumulate over time.
Can easily free up several gigabytes of space.
If you work on multiple projects or rebuild images often,
make it a habit to run these cleanup commands once a week.
Good luck!💫
Top comments (0)