Blog / For developers

Docker.raw taking up too much space on your Mac? What to prune first

Docker's disk image claimed 460 GB on my Mac. It used 25. How to read Docker's real size, and prune the right things in the right order.

Docker starts with my Mac, so I rarely open its window. When I went looking for what was using so much space, its disk image said 460 GB. My whole disk is 460 GB, so for a second I thought Docker had swallowed the Mac.

It hadn’t. The file really took 25 GB, and Docker’s own numbers put about 7.4 GB of unused images inside it. Getting from the first number to the last took three commands.

TLDRLook first, then prune

Docker Desktop keeps everything in one disk image file, Docker.raw, and many tools show its maximum size instead of what it uses. Measure it with du -h, then run docker system df to see the real split between images, containers, volumes, and build cache. Prune stopped containers, unused images, and build cache first. Leave volumes for last, because they hold databases and other data.

Why Docker looks bigger than it is

Docker Desktop runs containers inside a small Linux virtual machine. That machine’s disk is a single file, Docker.raw, inside ~/Library/Containers/com.docker.docker. It’s a sparse file: it can grow up to a set size, and it only takes real disk space as it fills.

That’s why the two common ways to measure it disagree:

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

On my Mac, ls said 460 GB, the most the file is allowed to grow to. du said 25 GB, the space it really took. The second number is the one your disk feels.

Docker’s own Mac FAQ warns about this too: many tools report the file’s maximum size, not its actual size. Docker Desktop’s settings show both, plus where the file lives, under Resources, then Advanced.

Storage settings doesn’t show Docker by name either. On this Mac, Docker’s folder was one of the owners behind a 212 GB System Data bar, which is part of why System Data gets so big.

See what’s inside

Docker can tell you what’s inside that file. This command talks to Docker’s engine, so Docker Desktop has to be running for it to answer. On this Mac it’s set to start at login, so it already was:

docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          63        27        21.87GB   7.412GB (33%)
Containers      31        10        262.1MB   843.8kB (0%)
Local Volumes   20        18        2.266GB   162MB (7%)
Build Cache     242       0         5.843GB   231.8kB

That’s my Mac on October 7. Images were most of it: 63 of them, 27 in use by a container, and 7.4 GB that Docker counts as reclaimable. The build cache held 5.8 GB, but Docker counted only 232 kB of it as reclaimable, so pruning it wouldn’t have freed much.

Volumes were the smallest line, 2.3 GB, and the one I’d be most careful with. They’re where a container keeps data that has to outlive it, like a project’s database.

The four sizes add up to about 30 GB, more than the 25 GB du reported, so read them as Docker’s own view of what it holds, not a breakdown of the file. Add -v to see every image, container, and volume with its own size.

What to prune, in order

Go from the safest to the riskiest, and run docker system df again after each step so you can see what came back.

  1. Remove stopped containers with docker container prune. It asks before it deletes anything.
  2. Remove images no container uses with docker image prune -a. Without -a, it only removes dangling images, the untagged leftovers from old builds. Either way, an image comes back the next time you pull or build it.
  3. Clear old build cache with docker builder prune. Check the Reclaimable column first: on my Mac it was almost nothing. The next build takes longer, then the cache fills back up.
  4. Only then look at volumes, one by one, with docker volume ls.
Volumes hold your data

docker volume prune removes unused anonymous volumes. With -a, it removes every unused volume, including named ones like the database for a project you haven’t started this week. Check each volume before you remove it, and skip -a unless you’re sure.

There’s also docker system prune, which does the first three in one go. Its help text on this Mac, Docker 29.9.2, says it leaves volumes alone unless you add --volumes, and even then it prunes only anonymous ones. Add -a and it removes every unused image, not only the dangling ones.

What I’d do: run docker system df first and prune nothing until you’ve read it. On my Mac, the 7.4 GB of unused images was the only part worth a second look.

When the space doesn’t come back

Pruning frees space inside the virtual machine’s disk. Measure Docker.raw again with du -h afterward to see what your Mac actually got back.

Docker’s FAQ says space is freed when images are deleted, and it can take a few minutes to show up on the Mac. Files you delete inside a running container don’t free space automatically. So if the number barely moves, wait a few minutes and measure again before you try anything else.

If you want Docker to take less room

Docker Desktop’s settings have a disk usage limit, under Resources, then Advanced. The FAQ has a warning about lowering it: when you reduce the maximum size, the current disk image is deleted, and every container and image goes with it.

The same page says not to move Docker.raw in Finder, because Docker Desktop can lose track of it. If you want it on a bigger drive, change the disk image location in those settings instead.

If you’ve stopped using Docker entirely, quitting it isn’t enough. The disk image stays. Docker’s troubleshooting page lists Clean up data, which destroys all local containers and images and keeps your settings, and Uninstall for removing Docker Desktop itself.

What Diskling shows here

Diskling reads Docker’s own numbers and offers only what Docker counts as unused: images no container needs, stopped containers, and build cache. It never touches volumes. It runs Docker’s own prune after you’ve reviewed it, then measures the disk again.

Get Diskling

Before you prune anything, run du -h on Docker.raw and docker system df, and write both down. Then you can measure what each step really gave back.

On my Mac, those commands turned 460 GB into 7.4 GB of unused images. That 7.4 GB is the only part I’d prune, and only after checking which images I still need.

Questions people ask

Why is Docker using too much space on my Mac?

Docker Desktop keeps all its images, containers, volumes, and build cache in one file, Docker.raw. ls and many other tools show that file’s maximum size, which on my Mac was 460 GB. Run du -h on it for the real size, then docker system df to see which part is taking the space.

Is it safe to delete Docker.raw?

I wouldn’t touch it in Finder. Docker’s FAQ warns that even moving the file there can make Docker Desktop lose track of it. To start over, use Clean up data in Docker Desktop’s troubleshooting options, which destroys local containers and images and keeps your settings.

Does docker system prune delete volumes?

Not by default. By its help text, docker system prune leaves volumes alone unless you add --volumes, and that prunes only anonymous volumes. Named volumes, like a project’s database, stay.

Why didn’t pruning free up space on my Mac?

Docker’s FAQ says it can take a few minutes for freed space to show up on the Mac, and that files deleted inside a running container don’t free space automatically. Measure Docker.raw with du -h again after a few minutes.

Know someone with a full Mac? Send them this.
Nazmoon Munny
Nazmoon Munny Chief Overthinker at Dotbrain

I'm the product manager for Diskling, which mostly means asking "but what if" until nothing breaks. I studied soil science before software, and outside work it's family, farming and whatever I'm learning next.

Comments

No comments yet. Tried this on your Mac? Tell me how it went.

Please add your name.

That email doesn’t look right.

Add a few words first.

I read every comment before it shows up.