How to free up disk space used by Docker
When you use Docker on a daily basis, your disk can get full of unnamed images, stopped containers, dangling volumes and build cache. Here is how to clean all that up.
First, check how much space Docker is using:
docker system df
This will show you images, containers, volumes and build cache with their sizes.
To remove all stopped containers, dangling images and unused networks in one go:
docker system prune -f
If you also want to remove dangling volumes:
docker system prune -af --volumes
Just be careful with the --volumes flag. Once they are gone, any data stored in anonymous volumes is lost.
Now if you want to remove only what is old:
docker system prune -af --filter "until=24h"
The --filter flag removes everything created or used more than 24 hours ago.
That's all for now.
Thanks for reading!
Top comments (0)