DiskAtlas DiskAtlas
Download Free DMG
Developer Storage

How to Reclaim 50+ GB of Docker Disk Space on Mac (Docker.raw Shrink Guide)

Docker Desktop on macOS is essential for containerized development, but over time its virtual disk image (Docker.raw) can quietly balloon to 60 GB, 100 GB, or moreโ€”and deleting containers doesn't automatically shrink the file.

Because macOS is Darwin-based (not Linux), Docker Desktop cannot run Linux containers natively. Instead, it spins up a lightweight Linux hypervisor virtual machine.

The entire Linux root filesystem, containerd images, build caches, and volumes are stored inside a single virtual sparse disk file located at:

DOCKER VIRTUAL DISK PATH
~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

1. The Sparse Disk Shrink Problem

When you download a 10 GB Docker image, Docker.raw expands to hold it. When you later run docker rmi to delete the image, the free space is reclaimed inside the virtual Linux ext4 filesystem, but macOS APFS does not know that those host SSD blocks can be trimmed.

As a result, your host Mac storage remains hostage to an oversized virtual disk.

2. Purging Build Caches & Dangling Layers

Step 1: Inspect Current Docker Usage

Run Docker's built-in disk visualizer to see how space is allocated:

TERMINAL COMMAND
docker system df

Step 2: Wipe BuildKit Cache (Huge Space Saver)

BuildKit retains intermediate build layers for multi-stage Dockerfiles that can easily total 30โ€“50 GB:

TERMINAL COMMAND
docker builder prune -a -f

Step 3: Deep System Prune

Remove stopped containers, unused networks, and dangling images:

TERMINAL COMMAND
docker system prune -a --volumes -f
โš ๏ธ
Note on --volumes: The --volumes flag will remove local persistent volumes not attached to running containers. If you have database containers with persistent data, verify them first.

3. Compacting Docker.raw on APFS

In modern Docker Desktop versions (v4.25+), you can trigger an explicit disk trim through the GUI:

  1. Open Docker Desktop.
  2. Click the Troubleshoot icon (the bug icon at the top right).
  3. Click Clean / Purge data.
  4. Select Trim disk image.

Alternatively, if you want a complete reset:

RESET DOCKER DISK
rm -rf ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

Spot Virtual Disks Instantly with DiskAtlas

DiskAtlas highlights virtual disks from Docker, UTM, and Parallels directly in the interactive treemap and Big Wins Reclaim catalog.

Try DiskAtlas Free

4. Best Practices for Lean Docker Storage

  • Use Multi-Stage Builds: Keep production image sizes under 150 MB.
  • Enable VirtioFS: Enables ultra-fast file system sharing with minimal overhead on Apple Silicon.
  • Cap Virtual Disk Limit: Set Docker Desktop Virtual disk limit to 32 GB or 64 GB under Settings โ†’ Resources โ†’ Virtual disk limit.
Share this article: