1. The Docker.raw Growing Disk Problem
On macOS Sonoma and Sequoia, Docker Desktop stores container layers, volumes, and build caches in a virtual disk image located at:
This file automatically expands as you pull images and build Dockerfiles. However, when you delete images inside Docker, the host macOS APFS filesystem does not automatically shrink the Docker.raw file on disk.
2. Pruning vs. Disk Compaction
There is an important distinction between freeing container layers inside the VM and reclaiming the physical disk space on your Mac:
- Docker System Prune: Deletes stopped containers, unused networks, and dangling layers inside the virtual filesystem.
- APFS TRIM Compaction: Reallocates zeroed blocks from the virtual disk back to macOS free storage.
3. Step-by-Step Pruning Commands
4. Compacting the Sparse Virtual Disk
In modern Docker Desktop versions, enabling VirtioFS and dynamic disk trimming allows Docker to issue fstrim commands directly to the macOS APFS container.