Glint › Guides

Guide

How to clear Docker disk space on a Mac

Last updated

Docker Desktop on a Mac runs containers inside a small Linux virtual machine, and everything that VM stores (images, containers, volumes, build cache) lives in one big disk image. That is why Docker can quietly take 30, 60 or 100 GB, and why deleting the wrong file can wipe all of it at once.

Where Docker keeps its data on macOS

The VM disk is a single file:

~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

Docker.raw is a sparse file: its apparent size is the maximum you allowed (often 64 GB or more), but only the blocks actually written take space on the SSD. Finder shows the apparent size, which looks alarming. To see what it really uses:

du -h ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

Older Docker Desktop versions used Docker.qcow2 instead; the advice below applies to both. Docker Desktop's logs live next to it, in ~/Library/Containers/com.docker.docker/Data/log.

Step 1: see what's using space inside Docker

Start with Docker's own accounting. With Docker Desktop running, open Terminal:

docker system df
docker system df -v   # per image, container and volume

The output has four lines: Images, Containers, Local Volumes and Build Cache, each with a RECLAIMABLE column. That column tells you how much a prune could free.

Step 2: prune what you don't need

Go from the safest command to the most aggressive, and read the confirmation prompt each time:

# stopped containers, unused networks, dangling images, build cache
docker system prune

# also every image not used by a container (they will be pulled again)
docker system prune -a

# build cache only (often the biggest item for people who build images)
docker builder prune

# unused volumes - this is where databases live, so be sure
docker volume ls
docker volume prune

Volumes hold data. A local Postgres or MySQL container usually keeps its database in a volume. docker system prune leaves volumes alone unless you add --volumes. On recent Docker versions docker volume prune only removes anonymous volumes; named volumes need --all. Export anything you care about first.

Removing individual items is often better than a blanket prune:

docker image ls --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}"
docker image rm <image>
docker rm <container>

Step 3: let macOS get the space back

After a prune, the Linux VM frees the blocks and current Docker Desktop versions hand them back to macOS automatically, because Docker.raw is sparse. It can take a minute. Check again with the du -h command above, or in System Settings › General › Storage.

If the file hardly shrinks, restart Docker Desktop. If it still doesn't, use the reset in Step 5.

Step 4: cap the disk image size

In Docker Desktop, open Settings › Resources › Advanced and lower the disk image size limit (called "Virtual disk limit" in some versions). Docker never grows past this limit, so it's a simple guard against a runaway build cache. Lowering the limit can require Docker to recreate the disk image; Docker warns you if data will be lost.

Step 5: the clean slate

If you'd rather start fresh, use Docker's own reset instead of deleting files: click the Troubleshoot (bug) icon in Docker Desktop and choose Clean / Purge data. This deletes all images, containers, volumes and build cache, and leaves Docker in a working state. Everything you need will be pulled or built again.

Why not just delete Docker.raw?

Deleting Docker.raw by hand does the same as a purge, with two extra risks:

If you do decide to remove it, quit Docker Desktop first (Docker menu bar icon › Quit Docker Desktop) and make sure no com.docker processes are left in Activity Monitor.

Other places Docker and containers use space

Doing it with Glint

Glint does not reach inside Docker's disk image, so pruning images and volumes is still a job for the docker commands above. What Glint does is the surrounding cleanup: Smart Clean lists Docker Desktop's logs next to Xcode, npm, pnpm, Gradle and Cargo caches, and the Space Map shows how much the Docker container folder takes. While Docker Desktop is running, Glint skips its VM files, logs and sockets and tells you why, so nothing is removed under a running VM; quit Docker and scan again to include them.

FAQ

Can I delete Docker.raw?

Only if you accept losing every image, container, volume and build cache inside it, and only after quitting Docker Desktop. The cleaner way is Docker Desktop's Troubleshoot › Clean / Purge data, which recreates an empty disk image for you.

Does docker system prune delete my volumes?

Not by default. Volumes are only pruned when you add --volumes, and on recent Docker versions that removes anonymous volumes only. Named volumes need docker volume prune --all or docker volume rm.

Why does Finder show Docker.raw as 64 GB when my disk barely changed?

Docker.raw is a sparse file. Finder shows its maximum size, while the space really used on disk is smaller. Use du -h on the file to see the actual usage.

Glint is a free disk cleaner for macOS 14 Sonoma and later, on Apple Silicon and Intel. No limits, no account, and everything stays on your Mac.

Download for Mac

What Glint does · FAQ · Safe by design

Related guides