Docker.raw is taking up space on my Mac

Docker Desktop keeps every image, container and volume inside one big file. Here is how to see what is really in it and shrink it without losing data.

Where it is

 Terminal
~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

Its real size

Docker.raw is a sparse file. Finder and ls show the maximum size you allowed, not what it uses. Compare:

 Terminal
ls -lh ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
du -h ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

The du number is what it really takes on disk.

See what is inside

 Terminal
docker system df
docker system df -v

Free space, safest first

  1. Build cache (always rebuildable):
     Terminal
    docker builder prune
  2. Stopped containers, unused networks and dangling images:
     Terminal
    docker system prune
  3. Every image not used by a container (they download again on the next pull):
     Terminal
    docker image prune -a
Volumes hold data. docker system prune --volumes and docker volume prune delete volumes that no container uses right now, and a stopped database's data may be one of them. List them first with docker volume ls and back up anything you need.

Run du -h on Docker.raw again afterwards to see what you got back. You can also lower the maximum in Docker Desktop → Settings → Resources → Virtual disk limit.

Never delete Docker.raw by hand unless you want to lose every image, container and volume.

Questions

Why is Docker.raw so big?

Finder shows its maximum size because it is a sparse file. Use du -h to see the real size, and docker system df to see what fills it.

Is it safe to delete Docker.raw?

Only if you are fine losing every image, container and volume. Use docker system prune instead.

Let the raccoon do it, safely

Junk Raccoon finds this clutter for you, shows every file first, and keeps a one-click way back. Free beta for Mac.

Download for Mac