How to clear Docker's cache on Mac and reclaim gigabytes of disk space
Trying to clear Docker cache on Mac can be so frustrating when you run docker system prune commands only for it to say it reclaimed gigabytes, but your Mac storage doesn’t seem to acknowledge it.
I think the problem is that Docker cache isn’t one single thing. It can actually sit across different containers, images, even volumes, your build cache, on your macOS, and inside Docker Desktop’s own virtual disk.
I’ve put all the cleanup commands together that do work and the Mac-specific VM disk step that everyone seems to miss, plus how to stop Docker from eating up your storage again.
So what’s actually eating space?
I think the best place to start is by understanding which part of Docker is actually using up the space, so in Terminal, make sure Docker Desktop is up and running, then try the following commands to start investigating:
-
docker system df
This should give you a breakdown of Docker storage by type:
-
Images: downloaded or built images, including old versions you no longer use.
-
Containers: stopped containers that are still sitting on your Mac.
-
Local volumes: saved data used by containers. Be careful here, because volumes can contain databases or app data.
-
Build cache: temporary layers Docker keeps to speed up future builds.
Pay a bit of attention to all the reclaimable amounts, but don’t forget, reclaiming it inside Docker won’t always mean your macOS immediately shows the space as free.
Clear Docker cache on Mac by type
Now you’ve got an idea about what’s taking up space, you can clear Docker cache by type.
-
To remove stopped containers, run: docker container prune
-
For removing dangling images, run: docker image prune
-
To remove all unused images (not just dangling ones), use: docker image prune -a
I’d be a bit more careful with volumes, because they can contain databases, uploads, or even app data from containers you still need, so just go slowly here, and really make sure these are good to go.
-
docker volume prune
-
For build cache, run: docker builder prune
-
And if you want the all-in-one cleanup: docker system prune -a --volumes
Ok, so if you’ve tried this before, and this is where you’re getting frustrated, because the space isn’t reflected back in your Mac Storage, keep reading.
Why the space doesn't come back on Mac
This took me quite a while and several threads and help articles to figure out, but Docker Desktop runs your containers inside a lightweight virtual machine, and that VM uses a disk image (usually called Docker.raw or Docker.qcow2), which is what starts to grow in size as Docker stores all the usual images, containers, volumes, and build cache.
So, even after you run your regular prune commands, it doesn’t always shrink back again. Docker starts reporting its reclaimed loads of storage space, but your macOS still sees the VM disk image taking up the same amount of storage.
This is pretty much what’s driving users insane, but you can fix it.
Open up Docker Desktop and click the question mark icon next to the search bar > Clean / Purge data. This then removes the Docker data properly (so export anything important first).
You can also reset Docker Desktop’s VM disk, or lower the disk image size limit in Settings > Resources to force Docker to rebuild at a smaller footprint.
An even faster Terminal-based option is CleanMyMac CLI. Its clean dev command detects and clears cached data from Docker, Homebrew, npm, and other developer tools, so you don't have to remember every single prune command.
Install it with: brew install --cask macpaw/taps/cleanmymac-cli
Then run: cleanmymac clean dev
It scans first and shows what it found, grouped by tool. Use Space to deselect anything you want to keep, then press Return to confirm the cleanup (add --force to skip the review entirely).
The public beta is free, but it isn't open source. Check the full list of commands on GitHub.
Prevent all the Docker cache from building up
As we all know, a little bit of prevention is master in these kinds of scenarios. And once you’ve cleared Docker cache, you basically need to think about how you can stop it from building up all over again.
First up, add a .dockerignore file to your projects. This will keep any unnecessary files out of the build context (node_modules, logs, local env files, screenshots, and old exports). A smaller build context means smaller, faster builds.
Next, use multi-stage builds where possible. They let you use temporary build layers without carrying all of them into the final image.
It also helps to tag images properly and prune old ones regularly instead of letting every experiment sit around forever. For a low-effort habit, run this once a week:
docker system prune -f
Just avoid adding --volumes to an automated cleanup unless you’re completely sure you won’t delete container data you still need.
If Docker isn't the only thing eating your storage
I don’t think it’s any secret to anyone out there that Docker can take up a ridiculous amount of room, but I think it’s rarely the only reason a developer Mac runs low on space.
Any build of your old Xcode caches, all your Homebrew files, npm packages, logs, installers, even downloads, and random project folders are most likely to be a big contributing factor.
So, once you’ve got Docker itself back under control, it’s worth taking a moment to do a bit of a bigger system-wide cleanup.
CleanMyMac’s Cleanup feature is my go-to at the moment. If you haven’t tried it yet, this tool can scan for all your system junk in a couple of clicks.
Start your free CleanMyMac trial — you can really test all features during that trial period too.
Clearing Docker cache on a Mac might start out as a bit of a headache, but once you know the full picture, it’s possible to get your Mac to reflect the reclaimed space.