Reclaiming Space on macOS from Docker by Pruning Docker.raw
Docker on macOS stores its container data in a virtual disk file called Docker.raw
. This file is used by Docker's internal virtual machine (VM) and can grow dynamically as more containers and images are created. Over time, even when containers are deleted, Docker.raw
can take up substantial disk space.
I recently encountered this issue, where my Docker.raw
file showed a size of 60G:
$ ls -lh ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
However, the actual disk usage was 31G:
$ du -sh ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
The discrepancy occurs because Docker.raw
is a sparse file. While it can potentially use 60G, it only occupies 31G of actual disk space.
To reclaim space, you can clean up unused data with:
$ docker system prune
Note: Space is only freed when images are deleted. Space inside running containers is not automatically reclaimed. To trigger space reclamation, run:
$ docker run --privileged --pid=host docker/desktop-reclaim-space
For more details, refer to the official Docker documentation: Docker Desktop FAQs for macOS.