Pruneo logoPruneo

Docker prune on Mac: free disk space without losing your data

Short answer

Run docker system df to see what is reclaimable, then docker system prune to remove stopped containers, unused networks, dangling images and unused build cache. Add -a only if you accept downloading images again, and --volumes only if you know what is in your anonymous volumes. On Mac, all of this lives inside one Docker Desktop disk image, so delete data with Docker commands, never by touching that file.

Docker Desktop on Mac runs Linux inside a small virtual machine. Every image you pull, every container you stop and every layer you build stays inside one disk image file. That file grows quietly, and Finder can’t tell you what is inside. This guide shows how to measure Docker’s usage, which prune command to run, what each flag deletes, and how the disk image itself works.

Step 1: see what Docker is using

Start with a command that only reads:

docker system df

It shows a table with Images, Containers, Local Volumes and Build Cache, with columns for Total, Active, Size and Reclaimable (docker system df). Reclaimable is the space you can get back without touching what is in use.

For details per image, container and volume:

docker system df -v

Look at three things:

  1. Images with no running container. Some are “dangling”: old layers with no tag, usually left after a rebuild.
  2. Build Cache. On machines that build images often, this is commonly the largest line.
  3. Local Volumes. These usually hold real data, like a local Postgres or MySQL database. Treat them with care.

Step 2: the default prune

The standard cleanup is:

docker system prune

According to the official reference, it removes:

Volumes are not removed by default. Docker asks for confirmation before it deletes anything.

Prune only old things

If you want to keep recent work, filter by age. The until filter accepts durations such as 24h:

docker system prune --filter "until=24h"

That removes only containers, images and networks created more than 24 hours ago.

Step 3: more aggressive options

Remove all unused images with -a

docker system prune -a

With -a, Docker removes every image without at least one container associated to it, not only the dangling ones, and all build cache.

Remove anonymous volumes with –volumes

docker system prune --volumes

With --volumes, Docker also removes anonymous volumes not used by at least one container.

Combining both, docker system prune -a --volumes, is the most destructive option. Use it only on a machine where you can rebuild everything from scratch.

Step 4: clean only the build cache

If docker system df shows that Build Cache is the problem, you don’t need to touch images or containers:

docker builder prune

By default it removes only dangling build cache (docker builder prune). Useful options:

Step 5: understand the Docker Desktop disk image

On Mac, Docker Desktop stores all Linux containers and images in a single disk image file. Docker’s documentation shows it at ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw (Docker Desktop for Mac FAQs). You can see its location in Settings > Resources > Advanced.

Its real size is smaller than it looks

Docker.raw is a sparse file. Docker notes that many tools report the maximum file size, not the actual size. To see the real size, run this in that folder:

cd ~/Library/Containers/com.docker.docker/Data/vms/0/data
ls -klsh Docker.raw

The first column is the space really used; the size column is the maximum.

Prune frees space, deleting files inside containers doesn’t

Docker says space is only freed when images are deleted. Space usually returns to macOS within seconds for a Docker.raw file. If it doesn’t, Docker documents this command to trigger it:

docker run --privileged --pid=host docker/desktop-reclaim-space

The disk usage limit in Settings

In Settings > Resources > Advanced, Docker Desktop lets you set the maximum disk space the engine can use (Docker Desktop settings). Raising it gives Docker room. Lowering it is not a cleanup tool:

Never delete Docker.raw by hand

Deleting or moving the file from Finder is the same as wiping Docker: images, containers and volumes go with it. If you want a clean start, use Docker’s own reset option on purpose, knowing what you lose. For normal cleanup, prune commands are enough.

A safe routine

  1. docker system df to see what is reclaimable.
  2. docker system prune once a week, or with --filter until=168h to keep the last week.
  3. docker builder prune when the build cache grows.
  4. -a and --volumes only when you know what you lose.

Run docker system df again after each step to see how much space came back.

Next steps

Docker is rarely the only developer tool filling your disk. If you build Apple apps, read how to delete Xcode DerivedData safely. For JavaScript projects, see how to clean node_modules and npm, pnpm and yarn caches. And for the rest of your Mac, start with how to free up space on Mac or try Pruneo, which is free.

FAQ

Does docker system prune delete volumes?

Not by default. Volumes are kept unless you add --volumes, and even then Docker removes anonymous volumes not used by any container.

Why is Docker.raw so big on my Mac?

Many tools show the maximum size of the disk image, not the space it really uses. Docker documents ls -klsh Docker.raw to see the real size in the first column.

Can I just delete Docker.raw?

Deleting it removes all your containers, images and volumes at once. Use prune commands instead, or reset Docker Desktop on purpose if you really want to start from zero.

What is the difference between docker system prune and docker builder prune?

docker system prune cleans containers, networks, images and build cache together. docker builder prune only cleans the build cache, which is often the largest part.

Try it with Pruneo

Free for macOS 14 or later. Anything it cleans can be restored from quarantine.

Pruneo is for Mac

Send yourself the link and download it on your Mac. Free, no account needed.

Email it to me
Download anyway