Home / Guides / Docker.raw Is Eating My Mac: How to Shrink It
Docker.raw Is Eating My Mac: How to Shrink It
Before you start
The commands below are provided as-is, without warranty of any kind. Several of them delete containers, images or volumes, and the deletion is permanent: there is no Trash and no undo. Volumes can hold databases and other data you cannot download again. Make a backup first, and note that Docker Desktop's own settings list an option to include its virtual machine in Time Machine backups (disabled by default in the current documentation), so a Time Machine backup may not contain your Docker data. Paths, menu names and command output vary by Docker Desktop version. Use at your own risk; Yogi Software Works is not liable for data loss or other damage resulting from these commands. See our Terms.
Docker Desktop for Mac keeps all of its containers, images and volumes inside one very large file called Docker.raw. That file can look much bigger than the space it really uses, and deleting things inside Docker may not make the number in Finder smaller. This guide shows how to find the file, read both of its sizes, see what is inside, and free space using Docker's own commands and settings. The manual steps work without any paid software.
Disclosure: I'm the developer of AiKiller (Yogi Software Works), a paid Mac app that can do part of this cleanup. The manual steps below work without it.
Step 1: Find Docker.raw
Per Docker's documentation, Docker Desktop stores Linux containers and images in a single large disk image file on your Mac, and you can see its location, its maximum size and the space it actually uses in Settings → Resources → Advanced. The same page uses this folder in its example:
cd ~/Library/Containers/com.docker.docker/Data/vms/0/data
ls -klsh Docker.raw
The file name and location can differ: the documentation also mentions an older Docker.qcow2 format, and the location can be changed in the settings, so treat the Settings screen as the authority for your install. Do not move or delete the file in Finder; the documentation warns that moving it there can make Docker Desktop lose track of it, and says to use the location setting instead.
Step 2: Read the two sizes
Docker.raw is a sparse file. Its maximum size (what many tools report) can be much larger than the space it takes on your disk. Docker's documentation says that many tools report the maximum file size, not the actual size, and gives the ls -klsh command above, where the first column is the actual size in KB and the size column is the maximum.
To compare the two yourself (read-only), run these in that folder:
ls -l Docker.raw
ls -ls Docker.raw
du -h Docker.raw
ls -l shows the maximum size in bytes. In ls -ls, the number in the first column is the space actually used, counted in 512-byte blocks, and du -h shows the same space in readable units. To test this, we created a placeholder sparse file with a 64 GB maximum size and wrote 100 MB of data into it on a macOS virtual machine (this was not a real Docker file). ls -l and ls -lh showed 68719476736 bytes (64G), ls -ls showed 204832 blocks, ls -klsh showed 102416 KB, and du -h showed 100M. Finder or other tools may show either figure depending on how they read the file, so use the commands above when the numbers matter.
The actual size can still be large. If it is, the space is used by things inside Docker, which the next step shows.
Step 3: See what is inside Docker
Docker Desktop must be running for these read-only commands. docker system df prints the space used by images, containers, local volumes and build cache and how much of it Docker considers reclaimable (see the docker system df reference); the -v flag lists each item:
docker system df
docker system df -v
docker image ls
docker container ls -a
docker volume ls
Look at the volumes list before you delete anything. A volume is where a container keeps data such as a database. A volume that no container is using right now may still be a database you plan to start again.
Step 4: Remove what you do not need
Warning: the commands in this step permanently delete data inside Docker. Make a backup first; for a database, export it with the database's own tools, because a Time Machine backup may not include Docker's data (see the note at the top). Substitute the real names or IDs from the lists above for the placeholders.
Remove specific items
The most controlled approach is to remove items one at a time. Stop a container before removing it if it is running (the commands normally refuse to remove items that are in use):
docker container rm <container-name-or-id>
docker image rm <image-name-or-id>
Remove many unused items with docker system prune
docker system prune removes unused data in bulk. Per Docker's documentation, the plain command asks for confirmation and removes:
- all stopped containers
- all networks not used by at least one container
- all dangling images (untagged images that nothing refers to)
- unused build cache
docker system prune
Read the list Docker prints and answer N if anything on it is unexpected. A stopped container counts as unused, so check docker container ls -a first. Avoid the -f (--force) flag, which skips the confirmation prompt.
Two flags remove much more, and they are where data is lost:
-a(--all) removes all unused images, not just dangling ones. Those images may take a long time to download again, and an image you built locally may not exist anywhere else.--volumesalso removes anonymous volumes that no container is using. By default, Docker's documentation says volumes are not removed so that important data is not deleted, and this flag overrides that. A volume that holds a database can be deleted this way with no way to bring it back.
Use these two flags only after you have checked docker volume ls and docker system df -v and backed up anything you need. Do not combine them if you are not certain what is in each volume.
When does the file get smaller?
Docker's documentation says space is only freed when images are deleted, and not automatically when files are deleted inside running containers. For a file named Docker.raw, it says space on the host is reclaimed within a few seconds; for the older Docker.qcow2, a background process frees it after a few minutes. After deleting, run ls -ls Docker.raw or du -h Docker.raw again and compare the actual size, not the maximum.
The same page lists a command to trigger a reclaim at any time, which starts a privileged container. We did not run it, and you should read what it does before you do:
docker run --privileged --pid=host docker/desktop-reclaim-space
Step 5: Settings options that remove everything
These options are for when you accept losing the contents of Docker Desktop. Back up anything you need from your containers and volumes first.
- Lower the maximum disk size. In Settings → Resources → Advanced, Docker's FAQ describes a disk image size slider (the settings reference calls the setting Disk usage limit, so the name varies by version). The FAQ states that when you reduce the maximum size, the current disk image file is deleted and all containers and images are lost. Volumes are stored with the rest of Docker's data, so treat them as lost too.
- Troubleshoot → Clean up data. The troubleshooting documentation says this resets all Docker data without resetting to factory defaults, and that it results in the loss of existing settings. Older versions of Docker Desktop may call it Clean / Purge data; we could not confirm which versions use which label, so check the Troubleshoot menu in yours. Reset to factory defaults is a stronger option in the same menu.
- Move the file. If the disk is full but you want to keep your data, Disk image location in the same Advanced settings lets you move the file to a bigger drive, per the FAQ.
None of these is needed just to see a smaller number in Finder. If the actual size from Step 2 is small, the file is not using much space even when its maximum size looks large.
What this guide does not cover
Tested versus taken from documentation. We tested only the file-size commands (ls -l, ls -ls, ls -klsh, du -h) on a macOS 15.7.7 virtual machine, against a placeholder sparse file I created in the same folder layout. We did not install or run Docker Desktop for this page. The file location, the Settings and Troubleshoot menu names and behavior, docker system df, docker system prune and its flags, and the reclaim command come from Docker's documentation linked above and may differ in your version. The docs page for the Mac FAQ shows the location used above, and we did not check the location on a real Docker Desktop install.
Not covered: Docker data on other systems, container tools other than Docker Desktop (which store data in other places), Kubernetes data, and how to back up each kind of volume (see Docker's volumes documentation). If you run Ollama in a container, its models may be stored in Docker's disk image; for models stored by Ollama on your Mac, see Where Ollama stores models on Mac, and how to delete them.
Do this in one scan with AiKiller (free)
AiKiller's scan includes Docker. When Docker Desktop is running, it uses the Docker command line to list your containers and images, and marks images that a container uses. You can select containers (a running container is stopped first) and unused images to remove; AiKiller does not remove images that a container uses. It does not run docker system prune, does not remove volumes, networks or build cache, and does not resize or compact Docker.raw, so volumes and the settings options above remain manual steps. Scan Mode is read-only: it lists each item. Nothing is deleted until you switch to Clean Mode, select the items you want and type a confirmation code. Deletion is permanent and does not use the Trash, so back up anything you need first. AiKiller is free. Safety Shield (Applications screen only, on by default): when you remove an application, it keeps the credential files AiKiller recognizes, but recognition is limited to AiKiller's built-in detection rules, so other secrets may not be recognized. It does not apply to local model removal, which deletes everything you select.