How to free up Docker disk space on a Mac
Docker on a Mac runs inside a small Linux virtual machine, and every image, container, volume and build cache lives in that machine's disk image. Deleting files in Finder won't shrink it. Docker's own commands will, as long as you know which ones touch your data.
Where Docker Desktop keeps its disk
Docker Desktop stores everything in one file:
~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
It's a sparse file. Its stated size is the most it may grow to (the disk usage limit in Docker's settings), while the space it really takes is often much less. Finder and ls show the stated size, which is why Docker.raw so often looks huge. To see what it really uses:
cd ~/Library/Containers/com.docker.docker/Data/vms/0/data
ls -lh Docker.raw # the size it may grow to
du -h Docker.raw # the space it takes on your disk
Don't delete or move Docker.raw to save space. It holds every image, container and volume, including databases and anything else you've only stored in Docker. Use the commands below, or Docker Desktop's reset options, instead.
See what's using the space
With Docker running:
docker system df
docker system df -v # every image, container, volume and cache entry
The summary has four rows: images, containers, local volumes and build cache, each with a "Reclaimable" column. That column is a good guide to what the prune commands below will free. Build cache is often the largest after a few months of docker build.
What each prune command removes
| Command | Removes | Risk |
|---|---|---|
docker builder prune | Dangling build cache. Add --all for all unused build cache. | Low. The next build is slower. |
docker image prune | Dangling images (untagged layers left by rebuilds). Add --all for every image no container uses. | Low. Removed images are pulled or built again. |
docker container prune | Stopped containers. | Files written inside a container, outside a volume, go with it. |
docker system prune | Stopped containers, unused networks, dangling images and unused build cache. | As above. |
docker system prune --all | The same, plus every image no container uses. | You'll pull or build images again. |
docker system prune --volumes | The same, plus unused anonymous volumes. | Data in those volumes is gone. |
docker volume prune --all | Every volume no container uses, named ones included. | High: this is where databases keep their data. |
Each command lists what it's about to do and asks before it removes anything, unless you add -f. Nothing goes to the Trash.
A safe order to work in
Start with what rebuilds itself:
docker builder prune --all
docker image prune
To keep recent cache and only clear the old, filter by age:
docker builder prune --all --filter until=168h # older than a week
Then stopped containers and images you no longer use. Check docker ps -a first: a stopped container may be one you meant to start again, with changes inside it that aren't in any image.
docker ps -a
docker system prune --all
Be careful with volumes
Volumes are where containers keep data meant to outlive them: Postgres and MySQL data directories, uploaded files, caches you might want back. A volume counts as "unused" whenever no container is attached to it, including when you've just run docker compose down and plan to bring the project up again tomorrow.
docker volume ls
docker volume ls --filter dangling=true # volumes no container uses
Since Docker Engine 23, docker system prune --volumes and plain docker volume prune only remove anonymous volumes (the ones with long random names). Named volumes, such as myapp_pgdata, are only removed by docker volume prune --all or docker volume rm. Remove volumes by name when you're sure, rather than in bulk:
docker volume rm old-project_pgdata
If a volume holds the only copy of a database you care about, dump it first (for example with pg_dump run inside the container) and keep the dump outside Docker.
Docker Desktop's own settings
Two things in Docker Desktop are worth knowing:
- Disk usage limit. In Settings, under Resources and then Advanced, you can set the most the disk image may grow to. Lowering it can mean Docker has to delete images to fit, so check what you'd lose first.
- Clean / Purge data. In the Troubleshoot screen (the bug icon), this deletes all of Docker's data: every image, container and volume. It's the right tool when you want to start again from nothing, and the wrong one otherwise.
After pruning, du on Docker.raw should drop, though it can take a minute for Docker to hand the freed blocks back to macOS.
Colima and OrbStack
Other ways of running Docker on a Mac keep their disks elsewhere, but the same docker prune commands work against them, because they talk to the engine inside the virtual machine.
- Colima keeps each machine in
~/.colima/_lima, with the container data disk in~/.colima/_lima/_disks.colima pruneclears only Colima's downloaded assets, not your containers.colima deleteremoves the whole machine and its settings, andcolima delete --dataremoves the container data too. - OrbStack keeps its data in a disk image inside
~/Library/Group Containers(a folder whose name ends indev.orbstack), with settings in~/.orbstack. Usedockercommands, or OrbStack's own settings, rather than touching those files.
How ElfClean does it
ElfClean doesn't clean Docker's disk image. It belongs to another app's protected container, and removing it would delete every container and volume at once, so ElfClean only measures it. On the AI & coding screen, "Docker and virtual machine storage" lets you choose Docker.raw or another virtual machine disk and shows the space it takes on disk next to the most it may grow to, with a link to Docker's cleanup instructions.
The same screen has a "Reclaim with the tool's own command" section, which lists docker system prune for Docker, Colima and OrbStack, explains what it removes and that volumes stay unless you add --volumes, and has a button to copy it. ElfClean never runs these commands itself; you paste them into Terminal.
What it does clean are the caches around your projects, such as package downloads and build folders in projects you haven't touched for a while. Those go to the Trash, and History can put them back.
More guides
- How to delete old node_modules folders on a Mac safely
- Where Ollama and Hugging Face store models on a Mac, and how to remove them
- What Claude Code, Codex and Cursor leave on your Mac
- How to clear Xcode DerivedData, simulators and device support
- What System Data is on a Mac, and how to make it smaller
- How to find large files and duplicates on a Mac
- Clear pip, uv, Homebrew, Cargo and other caches on a Mac
- Mac cleaners for developers compared: CleanMyMac alternatives