Docker.raw keeps growing: why the file never shrinks and how to actually reclaim the space

You ran docker system prune -a, freed 30 GB inside Docker — and ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw is still exactly as huge as before. That is not a bug you can prune away: the disk image file only grows, never shrinks, by design.

Why it happens

Docker Desktop runs containers inside a thin-provisioned virtual disk (Docker.raw on macOS, DockerData.vhdx on Windows). Deleting images inside the VM marks blocks as free inside the virtual filesystem, but the host file keeps its high-water mark — like a hotel that never un-reserves floors. Over months of builds, Docker.raw ratchets up to the largest size it ever needed.

Fix 1: the supported shrink (Docker Desktop ≥ 4.30)

Settings → Resources → Disk → "Clean / Purge data", or newer builds' Shrink disk image action. This reclaims unallocated blocks. If your version has it, stop reading — this is the official path.

Fix 2: rebuild the image at a sane size

  1. docker system df — note real usage (usually 5-15 GB, not the 60 GB the file claims)
  2. Export what matters: docker save your must-keep images, or script them in a compose file
  3. Quit Docker Desktop
  4. Delete the image: rm ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
  5. Start Docker Desktop — it creates a fresh image at the size set in Settings → Resources → Disk image size (set it to a hard cap, e.g. 64 GB)
  6. Restore images with docker load or rebuild from compose

The rebuild takes minutes and the new file starts small. Keep "disk image size" capped so it cannot ratchet past a sane bound again.

Fix 3: stop the ratchet at the source

Related reading

For the general container/image cleanup commands, see our Docker disk cleanup guide. Docker is one of the biggest System Data contributors on developer Macs — the full triage order is in the System Data breakdown, and once Docker is tamed, a survey with DaisyDisk or a maintenance pass with MacCleaner PRO handles the rest.