Mopup › Guides › Docker

How to free up Docker Desktop disk space on a Mac

On a Mac, Docker Desktop keeps every image, container, volume and build cache inside one large disk image. It grows as you pull images and build, and nothing in it goes away until you remove it with Docker.

Where the space goes

Docker Desktop runs a small Linux virtual machine, and that machine's disk is a single file:

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

Finder may show its maximum size. To see how much space it really takes on your Mac:

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

Don't delete this file to save space: that erases everything in Docker at once. Use the commands below.

See what's using it

With Docker Desktop running:

docker system df

It shows how much space images, containers, local volumes and the build cache take, and how much of each can be reclaimed.

Reclaim space, safest first

  1. The build cache. docker builder prune -a deletes all build cache not in use. Your next builds take longer while it fills again.
  2. Stopped containers. docker container prune deletes every container that isn't running, with anything written inside it.
  3. Unused images. docker image prune -a deletes every image no container uses. They download or build again when you need them.
  4. Volumes, carefully. Volumes hold data, such as the contents of a local database. List them first with docker volume ls. docker volume prune deletes unused anonymous volumes; adding -a deletes every unused volume, named ones included.

Or all at once, except volumes:

docker system prune -a

This deletes stopped containers, unused networks, every unused image and the build cache. Volumes stay unless you add --volumes.

Docker gives the freed space back to macOS by itself, usually within seconds.

Set a limit

In Docker Desktop, Settings › Resources › Advanced has a limit for the disk image, so it can't grow past the size you choose.

Memory, too

Docker Desktop's virtual machine can also hold gigabytes of memory while it runs. Quitting Docker Desktop when you're not using it gives that memory back.

Mopup's Developer Tools on a demo Mac: a bun dev server idle for 2 hours holding 5.08 GB, then Docker Desktop holding 4.53 GB, an idle Gradle daemon, an iOS simulator and a Kotlin daemon, each with a Stop button.

Related guides