Docker.raw Is Huge on Mac: How to Shrink and Clean Docker
Docker.raw is huge on Mac? It is a sparse file. Check its real size, prune images, volumes and build cache, and cap Docker Desktop's disk image size.
Updated · 7 min read
Docker.raw looks huge on a Mac because it is a sparse disk image: Finder shows its maximum size, not what it actually uses. Check the real size with du -h, then reclaim space inside Docker with docker system prune, docker builder prune and, carefully, docker volume prune. Lower Docker Desktop’s disk usage limit to cap future growth.
TL;DR
# 1. Real size vs apparent size of the disk image
du -h ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
# 2. What is using space inside Docker
docker system df
# 3. Remove stopped containers, unused networks, dangling images, unused build cache
docker system prune
# 4. Remove the build cache (often the biggest item)
docker builder prune
- Volumes hold databases and other data you may want. Inspect them before pruning.
- To cap growth, use Settings > Resources > Advanced > Disk usage limit in Docker Desktop.
Where is Docker.raw on a Mac?
Docker Desktop runs containers inside a Linux virtual machine, and that VM’s disk is a single file:
~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
Every image, container, volume and build cache entry lives inside it. If you changed Disk image location in Docker Desktop’s settings, the file is wherever you pointed it. Older Docker Desktop versions used a Docker.qcow2 file instead of Docker.raw.
Why Docker.raw looks huge
Docker.raw is a sparse file. Its apparent size is the maximum the virtual disk may grow to, while macOS only allocates blocks that have actually been written. Finder’s Get Info and ls -l show the apparent size. du shows the real one.
Compare the two:
cd ~/Library/Containers/com.docker.docker/Data/vms/0/data
ls -lh Docker.raw # apparent size (the limit)
du -h Docker.raw # space actually used on disk
ls -lsh Docker.raw # both: allocated size in the first column
On the Mac we tested this on, ls -lh reported 460 GB for Docker.raw, while du -h reported 10 GB. The 460 GB is not taken from your disk. What matters is the real size, and that is what the commands below reduce.
That said, the real size only grows by itself. Old images, stopped containers and build cache keep accumulating until you remove them.
What is taking up space inside Docker?
Docker Desktop (or your Docker engine) must be running for these commands to work.
docker system df
This prints one row each for images, containers, local volumes and build cache, with a total size and a reclaimable column. Reclaimable is roughly what pruning that category would free.
For the detail behind each row:
docker system df -v
That lists every image, container and volume with its size, and which ones are in use. For build cache specifically:
docker buildx du
How to clean Docker on Mac
Work from the safest command to the most aggressive. Each prune command asks for confirmation unless you pass -f.
Remove stopped containers
docker container prune
Containers that exited are removed. Running containers are untouched.
Remove unused images
docker image prune # dangling images only (untagged layers)
docker image prune -a # every image not used by a container
-a frees the most, but you will pull or rebuild those images the next time you need them.
Clean the Docker build cache
BuildKit keeps cache for every layer of every build. If you build images often, this is usually the largest reclaimable item.
docker builder prune # unused build cache
docker builder prune -a # everything, including cache the default keeps
To keep recent cache and drop the rest, filter by age:
docker builder prune --filter until=168h # older than 7 days
The next build of an image whose cache you removed starts from scratch.
Remove unused volumes (carefully)
Volumes are where containers keep persistent data, such as local Postgres or MySQL databases. Look before you delete:
docker volume ls
docker system df -v
Then:
docker volume prune # unused anonymous volumes
docker volume prune -a # all unused volumes, including named ones
A volume counts as unused when no container, running or stopped, references it. If you removed a project’s containers, its database volume is now “unused” too.
Everything at once
docker system prune # stopped containers, unused networks, dangling images, unused build cache
docker system prune -a # also every image not used by a container
docker system prune -a --volumes # also unused anonymous volumes
docker system prune prints exactly what it will remove and asks for confirmation. Start without flags and add them only if you need more space.
Does pruning shrink Docker.raw?
Pruning frees space inside the VM. On current Docker Desktop versions, those freed blocks are handed back to macOS automatically, usually within a few minutes. Check again with:
du -h ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
If the real size has not dropped after a few minutes, quit and reopen Docker Desktop, then check again.
How to cap Docker Desktop’s disk image size
Open Docker Desktop and go to Settings > Resources > Advanced:
- Disk usage limit sets the maximum size of the virtual disk. This is the apparent size you see in Finder. Lowering it caps how far Docker can grow on your Mac.
- Disk image location lets you move the disk image, for example to an external SSD.
Lowering the limit below what is already in use may require Docker Desktop to recreate the disk image, which deletes its contents. Docker Desktop warns you before it does that. Prune first, then lower the limit.
How to reset Docker Desktop completely
If you do not need anything inside Docker, the fastest way to reclaim all of it is to start over. In Docker Desktop, open the Troubleshoot screen and choose Purge data, which wipes images, containers, volumes and build cache. Reset to factory defaults, on the same screen, also resets your settings.
Deleting Docker.raw by hand with Docker Desktop quit has the same effect, and Docker creates a new empty disk on the next start. The in-app option is safer because Docker shuts the VM down cleanly first.
Colima notes
Colima runs Docker in a Lima VM instead of Docker Desktop. The docker CLI talks to whichever context is active:
docker context ls # the active context has a *
docker context use colima
All the docker ... prune commands above work the same once Colima is the active context and running (colima start).
Colima’s disk images live in your home folder. With Colima 0.10 they are:
~/.colima/_lima/_disks/colima/datadisk # container data (images, volumes)
~/.colima/_lima/colima/disk # the VM's root disk
Like Docker.raw, they are sparse files, so compare ls -lh with du -h. colima list shows each profile’s configured disk size.
Two Colima-specific commands help:
colima prune # removes cached downloaded assets (VM images)
colima delete --data # deletes the instance including container runtime data
colima delete is the equivalent of a factory reset: the next colima start begins from scratch. Whether space freed by a prune inside the VM is returned to macOS depends on your Colima version and VM type, so check with du -h afterwards.
OrbStack notes
OrbStack also runs Docker in a lightweight VM. On most setups its data is stored under ~/Library/OrbStack, and OrbStack is designed to return freed disk space to macOS on its own. The same docker system df and docker ... prune commands apply while OrbStack’s context is active.
Docker storage at a glance
| What | Where | Safe to delete? | How it comes back |
|---|---|---|---|
| Stopped containers | Inside the VM disk | Yes, if you do not need their filesystem | docker run again |
| Dangling images | Inside the VM disk | Yes | Not needed |
| Unused images | Inside the VM disk | Yes | docker pull or rebuild |
| Build cache | Inside the VM disk | Yes | Rebuilt on next build (slower) |
| Volumes | Inside the VM disk | Only if the data is disposable | Not recoverable |
Docker.raw |
~/Library/Containers/com.docker.docker/Data/vms/0/data |
Only to reset Docker entirely | Recreated empty on start |
Colima datadisk |
~/.colima/_lima/_disks/<profile> |
Only to reset Colima | colima start |
Docker’s disk image is one of the files that often makes macOS report a large System Data number; see why System Data is so large on a Mac. If your containers serve JavaScript projects, deleting node_modules recursively is the next easy win, and the guide to freeing up space on a Mac for developers covers the rest.
Do it in one click with DevCleanup
DevCleanup’s Docker screen puts Docker’s disk image and what is reclaimable inside it in one view, measured by real space on disk rather than the sparse file’s apparent size, so you see what a cleanup will actually free before you run it. Every action is logged in History with how to restore it. Scanning is free; developer cleanup actions are part of Pro ($29 one-time).
Frequently asked questions
Can I delete Docker.raw on Mac?
Only if you are happy to lose every image, container, volume and build cache in Docker Desktop. Quit Docker Desktop first; it creates a new, empty disk image on the next start. The Purge data option in Docker Desktop's Troubleshoot screen does the same thing more safely.
Why does Docker.raw show 64 GB or more when I have few images?
Docker.raw is a sparse file. Finder and ls show its maximum size, which is the disk usage limit set in Docker Desktop, while only the blocks actually written use space. Run du -h on the file to see what it really occupies.
What is the safest command to clean Docker on Mac?
docker system prune. It removes stopped containers, unused networks, dangling images and unused build cache, and it asks for confirmation first. It does not touch volumes or images used by existing containers.
How do I clear the Docker build cache on Mac?
Run docker builder prune to remove unused build cache, or docker builder prune -a to remove all of it. Check how much there is first with docker system df or docker buildx du.