Reclaiming Docker disk space
Over time, Docker uses a lot of disk space by holding onto old images, stopped containers, and build caches. You can safely free up this space without deleting data your running containers need by using Docker’s built-in prune commands.
Clean up unused resources
The easiest way to clear out old files safely is to run a system prune. This command removes stopped containers, unused networks, and dangling images (images without a tag that are not used by any container):
docker system prune
Docker will ask you to confirm before it deletes anything.
Delete unused volumes
A standard system prune does not delete volumes, because they often hold database records or other persistent state. If you know you don’t need the data in your unattached volumes, you can remove them separately:
docker volume prune
Deep clean
To clear out absolutely everything that isn’t currently running, add the -a flag and the --volumes flag to the system prune. This deletes all unused images (not just the dangling ones), the build cache, and unused volumes.
docker system prune -a --volumes
Be careful with this command. It won’t break running containers, but it means Docker will have to re-download images the next time you spin up your older projects.
Where are Docker files stored?
If you use Docker Desktop on a Mac, it stores containers and images inside a virtual machine disk file rather than as normal directories you can browse. See the Docker Mac FAQ for the exact path on your system.
If you are trying to track down other hidden storage hogs, Docker is just one place to look. Check out our guide on how to free up disk space to quickly find the largest folders on your drive using FindBigFolders.