How to free Docker disk space safely
Images, build cache and volumes pile up quietly. Measure first, prune the safest category first, and leave volumes for last: they can hold real data such as local databases.
Measure first
docker system df # totals + RECLAIMABLE column docker system df -v # per image, container, volume, cache
Safest first: cache, stopped containers, dangling images
docker builder prune # dangling build cache (add -a for all unused build cache) docker container prune # stopped containers docker image prune # dangling (untagged) images
Each command asks for confirmation and prints how much space it reclaimed.
Unused images
docker image prune -a
Removes every image that no container uses (images of stopped containers are kept). You will pull or rebuild them next time. Fine on a laptop; think twice on a machine with slow or metered internet.
Careful: volumes
docker volume ls docker volume prune # Docker Engine 23+: unused anonymous volumes only docker volume prune -a # also unused NAMED volumes. Read the list before you confirm
What docker system prune actually does
docker system prune removes stopped containers, unused networks, dangling images and dangling build cache. -a adds all unused images; --volumes adds volumes. Avoid docker system prune -a --volumes unless you really mean "everything not running right now".
Docker Desktop (Mac) and WSL 2 (Windows)
macOS: images live inside a VM disk file, ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw. It is a sparse file: Finder shows its maximum size, while du -h shows what it really uses. Prune from the Docker CLI rather than touching the file.
Windows (WSL 2): data lives in a .vhdx file under %LOCALAPPDATA%\Docker\wsl (exact name varies by version). The file does not always shrink after a prune; compacting it requires wsl --shutdown and then a disk-compaction tool such as Optimize-VHD or diskpart.
Linux: data is under /var/lib/docker. Check it with sudo du -sh /var/lib/docker, but never delete inside it by hand; use the docker commands above.
Measure with devdisk
devdisk is a free, read-only scanner. With --docker it also reads docker system df (read-only) and puts Docker next to your npm, Xcode and model caches. It never runs prune. It never deletes anything; it only shows sizes and writes a cleanup script you read and run yourself.
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py
python3 devdisk.py --docker
Want one-click cleanup?
A planned devdisk desktop app for Mac and Windows: live treemap, cleanup that moves files to the Trash, scheduled scans. One email when it launches, with an early-supporter price. Your address is used only for that, and every email has an unsubscribe link.
FAQ
Will docker image prune -a delete images I need?
It deletes images that no container uses right now. You can pull or rebuild them, but that costs time and bandwidth.
Will pruning delete my database?
Not unless you prune volumes. docker system prune leaves volumes alone unless you add --volumes.
Does devdisk run docker prune?
No. It only runs the read-only docker system df when you pass --docker.