Why Docker.raw Is Huge on a Mac, and How to Shrink It Safely
It is one file, it is supposed to be large, and the only safe way to shrink it is from inside Docker.
Vì sao Docker.raw chiếm nhiều dung lượng trên Mac, và cách giảm đúng
On a developer’s Mac, a single file called Docker.raw is often the largest thing hiding in System Data. It can show as 64 GB, or more, in Finder, even when you only remember pulling a handful of images.
The file is doing what it was built to do. Docker Desktop keeps almost everything it stores — images, containers, volumes and the build cache — inside one virtual disk, so macOS sees one large object that fits no category. The mistake is to treat that object like a cache you can drag to the Trash. The file is not a cache. The safe work is to ask Docker what is unused, then remove those parts from the inside.
1. One file, holding almost everything Docker stores
Difficulty1 of 5
The usual path is:
~/Library/Containers/com.docker.docker/Data/vms
Inside that folder sits Docker.raw. Docker manages it. It is a sparse disk image, which is why Finder may show its maximum size rather than what is actually allocated. Docker Desktop shows both figures in Settings › Resources › Advanced, which is a better place to read the size than Finder is.
Two things follow from that layout. First, there is no folder of individual image files to tidy in Finder. Second, moving Docker.raw to the Trash is not a cleanup. It takes the images, the containers and the volumes with it, including data you may still need, and Docker will not be able to start from that file again.
Leave the file where it is. Work on what is inside it.
Docker.raw is the disk, not a leftover file. Do not move it in Finder.
2. Ask Docker what it can free, before deleting anything
Difficulty2 of 5
Docker has an official, read-only command for this:
docker system dfThe output is a table: images, containers, local volumes and build cache, each with a size and a RECLAIMABLE column. Reclaimable is Docker’s estimate of what unused images, stopped containers and build cache would free if you removed them. Volumes that are in use show up as not reclaimable, which is what you want to see.
If Docker is not running, start Docker Desktop and wait until the engine is ready, then run the command again. If the reclaimable column is small, the file is large because of things you are still using, and a prune will not give you the number Finder is showing.
This command changes nothing. It is the right first step every time.
The useful number is RECLAIMABLE, not the size of Docker.raw in Finder.
3. Three official commands, each of which asks first
Difficulty3 of 5
Once you have read the table, remove only the unused parts, from inside Docker. These three official commands match that idea, and none of them uses -f, so Docker asks before it deletes:
docker container pruneThat removes stopped containers. Running containers stay.
docker image prune -aThat removes images no container is using. Images you still have a container for stay. A removed image comes back the next time you pull or build it.
docker builder prune -aThat removes the build cache. The next build takes longer, which is expected.
Volumes are not in that list on purpose. A volume can hold a database or other data that does not come back from a pull. Leave volumes alone unless you know, for a specific named volume, that you do not need it.
Nothing these commands remove can be put back. There is no Trash for an image. Read the confirmation, then type y only if the description matches what you meant to delete.
Prune unused images, stopped containers and build cache from inside Docker. Leave volumes alone.
4. After a prune, the space may not show up at once
Difficulty2 of 5
Even after a successful prune, System Settings may still show a large number for a while. Docker returns blocks to macOS gradually as it shrinks the disk image. That is expected, and it is why a prune can look as if “nothing happened” if you only watch the Storage bar for a minute.
Give it time, then check docker system df again. The reclaimable column should be much smaller. The size of Docker.raw in Finder may also fall, though not always in one step, and not always all the way to the number Docker reported.
If you no longer use Docker Desktop at all, uninstalling the app is a separate decision, and it still should not start with dragging Docker.raw to the Trash. Use Docker’s own uninstall path so volumes and settings are handled in a way Docker documents.
Space returns gradually. Judge a prune by docker system df, not by a Storage bar that has not caught up yet.
Conclusions
Docker.raw looks like a leftover because it has an opaque name and a large size. It is not a leftover. It is the disk Docker is using. The two questions still help, once you apply them to what is inside the file:
- Is its cause still alive? A running container or a volume with data in it is in use. An image you have not run in months is not.
- If I remove it, does it come back? Unused images and build cache come back with a pull or a rebuild. Volumes and anything Docker has already deleted do not.
Never move Docker.raw in Finder. Ask Docker what is unused, prune that, and wait for the space to return.
For a wider look at why System Data gets so large, including this disk image and the other usual parts, read What Is System Data on a Mac? To measure the rest of the disk, how to check storage on a Mac walks through System Settings on every recent macOS version. And for the caches, build folders and leftover downloads that sit outside this file, Haikos Clean lists what it finds with a note on whether each one rebuilds, and moves only what you pick to the Trash first.
Questions people ask
Can I delete Docker.raw on a Mac to free space?
No. Docker.raw is the disk image Docker Desktop uses for almost everything it stores: images, containers, volumes and build cache. Moving it to the Trash will break Docker, and may delete volumes you still need. The supported way is to ask Docker what is unused, with docker system df, then remove those parts from inside Docker. The file itself stays where it is; it should get smaller over time as Docker returns blocks to the host.
Why is Docker.raw so much larger than docker system df reports?
Two different numbers are in play. Finder often shows the maximum size of the sparse disk image, not how much is actually allocated. docker system df reports what is inside: images, containers, volumes and build cache, and a reclaimable column for the unused parts. Even after a prune, Docker returns space to macOS gradually, so System Settings may not jump down in one step. The reclaimable figure is also smaller than the whole file, because volumes and images you still use stay.
Does docker system prune delete my volumes?
The commands in this guide leave volumes alone. docker container prune removes stopped containers. docker image prune -a removes images no container is using. docker builder prune -a removes the build cache. None of those uses -f, so Docker asks before it deletes. If you ever run a wider prune command, read the confirmation carefully: a flag that includes volumes would delete data that does not come back. When in doubt, stick to the three commands above.
Sources
Paths and commands were checked against these pages on the date above.