You check your disk and Docker is sitting on 40, 60, sometimes 100 GB. Or you look inside
~/Library/Containers and find a single file called Docker.raw that seems to be the size of a
small SSD.
Most of that space is safe to get back. One part of it is not, and it's the part that holds your local
databases. Here's how to tell them apart before you type prune.
Why Docker takes so much space on a Mac
Containers need a Linux kernel, so Docker Desktop runs a small Linux virtual machine. Everything Docker stores — images, containers, volumes, build cache — lives inside that VM's virtual disk, a single file:
~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
Settings → Resources → Advanced in Docker Desktop shows where your disk image is and the maximum size it's allowed to grow to.
Two things follow from that design:
- macOS can't see inside it. To Finder, the Storage panel and most disk tools, Docker is one big file. That's why it often ends up counted as "System Data" (we covered that bucket in "System Data" explained).
- It's a sparse file. Some tools report its maximum size rather than what it really uses. To see the real figure:
du -h ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
If du says 18 GB and Finder says 64 GB, du is the one telling you what's on your disk.
See what Docker is holding: docker system df
Before deleting anything, ask Docker for the breakdown. Docker Desktop has to be running:
docker system df
You get four rows: Images, Containers, Local Volumes and Build Cache, each with its total size and a RECLAIMABLE column — the part nothing is using right now.
For the detail, item by item:
docker system df -v
This lists every image, container and volume with its size, and which ones are in use.
One thing that confuses everybody: image sizes don't add up. Images share layers, so ten images built on the same base might list 1 GB each and take far less together. Trust the RECLAIMABLE total over your own sum of the image list.
What's safe to reclaim: images, build cache, stopped containers
These three come back on their own. The only cost is time and bandwidth the next time you need them.
| What | Command | How it comes back |
|---|---|---|
| Dangling images (untagged leftovers) | docker image prune |
They don't need to |
| All images no container is using | docker image prune -a |
docker pull, or the next docker compose up |
| Build cache | docker builder prune (add -a for all of it) |
The next docker build, just slower |
| Stopped containers | docker container prune |
docker run or docker compose up |
Or all of it at once, without volumes:
docker system prune -a
That removes stopped containers, unused networks, every image no container is using, and the build cache. It asks for confirmation and prints how much it freed.
A caveat on stopped containers. A container is disposable only if everything it wrote went into a
volume. If you've been running docker start on the same container for months and it keeps data in
its own filesystem, removing it removes that data. Check what's stopped first:
docker ps -a --filter status=exited
The one you should never prune blindly: volumes
Volumes are where containers keep data meant to outlive them: your local Postgres, MySQL, Redis or
Mongo, uploaded files, anything a docker-compose.yml mounts under volumes:. Nothing pulls them
back. If you delete a volume, the data in it is gone.
That's why the dangerous flag is this one:
docker system prune --volumes # careful
In current Docker versions it removes unused anonymous volumes — the ones with a long random name.
That sounds harmless until you remember that running a database image without -v stores its data in
an anonymous volume. Remove the container, prune with --volumes, and that database is gone. (Older
Docker versions removed every unused volume, named ones included, and docker volume prune -a still
does.)
Before touching volumes:
docker volume ls # every volume
docker volume ls -f dangling=true # the ones no container uses
docker system df -v # with their sizes
If a volume might matter, back it up first. This copies a volume called mydata into a .tgz in the
current folder:
docker run --rm -v mydata:/data -v "$PWD":/backup alpine \
tar czf /backup/mydata.tgz -C /data .
The same goes for Troubleshoot → Clean / Purge data in Docker Desktop: it resets Docker's disk completely, volumes included. Use it when you mean "start from zero", not "free some space".
Why Finder doesn't show the space right away
You prune 20 GB and Finder still shows the same free space. Nothing went wrong.
Docker frees the space inside its virtual disk first. Giving it back to macOS is a second step that, according to Docker's documentation, can take a few minutes after a prune. If you want it now, Docker documents a command that triggers it:
docker run --privileged --pid=host docker/desktop-reclaim-space
Then check with du -h on Docker.raw, not with Finder, for the reason above.
To keep the file from growing back to the same size, you can lower its maximum in Settings → Resources → Advanced. Be careful with that: shrinking the disk image limit can make Docker Desktop recreate it empty, which takes your images and volumes with it. Read the message before you confirm.
A routine that doesn't hurt
docker system dfto see where the space is.- Build cache first. It's often the largest, and losing it only makes the next build slower.
- Unused images next, with
docker image prune -a. You'll pull what you need again. - Stopped containers, after checking none holds data outside a volume.
- Volumes last, one by one, by name, only after you know what each one is. Never with a blanket flag.
If Docker isn't your only problem, the same "rebuildable first" logic applies to node_modules and
Xcode's DerivedData: see how to safely delete node_modules and Xcode
DerivedData.
How Depuria does it
Depuria is a free, native Mac app that shows what's filling your disk, and Docker is part of its Dev Cleanup section. On a sample dev setup we scanned, it found 3.5 GB to free (3.3 GB of unused images and 213 MB of build cache) and measured 752 MB of volumes it left alone.
- It runs
docker system dffor you and shows the same four classes: unused images, build cache, stopped containers and volumes, each with its size. - It frees images, build cache and stopped containers, all at once or image by image. Images a container is using are never offered.
- Volumes are measured, never deleted. The app labels them "Your data — Depuria never deletes these."
- It's honest about the undo: everything else Depuria removes goes to the Trash first, but Docker deletes these itself, so they can't go to the Trash and can't be recovered. The confirmation says so before you click.
- Because layers are shared, the space it reports as freed is measured after the cleanup, not predicted.
Docker Desktop has to be running for any of this; if it isn't, Depuria tells you instead of guessing.