Guide

docker prune: what each command removes, and what to keep

Which prune command removes what, why volumes are off limits, and why Docker's disk image lags behind.

By Rachid Almaach · November 2026

Docker keeps everything it ever built or pulled until you tell it otherwise: every layer of every image, the cache of every docker build, stopped containers, and the volumes behind them. On a Mac all of that lives inside one virtual disk, so no space left on device from a container often means Docker's disk is full while Finder still shows room. The prune commands get the space back, but they differ a lot in what they take, and one of them can delete your databases.

1. See where the space goes

docker system df
# per image, container, volume and cache entry
docker system df -v

The RECLAIMABLE column is what a prune could free. On a developer Mac the build cache is usually the biggest line, followed by images no tag points to any more.

2. The build cache

Every docker build leaves layers behind so the next build is fast. Layers that no build has used for a while stay anyway. This removes the cache no current build uses, and the next build simply rebuilds what it needs:

docker builder prune
# only entries older than three days
docker builder prune --filter until=72h
# all unused build cache, not only the entries no image refers to
docker builder prune -a

Without -a it is safe at any time except during a build. With -a the next build of every project starts from scratch and needs the network. Newer Docker versions can also cap the cache at a size; check docker builder prune --help for the flags your version has.

3. Images

Images without a tag (shown as <none> in docker images) are the old layers of images you rebuilt or pulled again. Nothing refers to them:

docker image prune

With -a Docker also removes every tagged image that no container uses, including the base images you pull every day. They come back with the next pull, so it is safe, just slow:

docker image prune -a

4. Containers and networks

Stopped containers hold their writable layer until you remove them. Compose stacks you brought down with docker compose stop instead of down leave them behind:

docker container prune
docker network prune

A stopped container with data written inside it rather than in a volume is gone after this. docker ps -a lists them first.

5. Everything at once

docker system prune

removes stopped containers, networks no container uses, untagged images and unused build cache in one go. Adding -a extends that to every image no container uses:

docker system prune -a

That is the command most people mean by "docker prune". After it, the next docker compose up pulls and builds everything again.

What is safe to delete, and what is not

Safe, because Docker recreates it on the next build or pull: the build cache, untagged images, tagged images you can pull again, stopped containers whose data lives in volumes or bind mounts.

Not safe: volumes. Volumes are where Postgres, MySQL, Redis and everything else in your Compose files keep their data. docker volume prune and docker system prune --volumes delete the ones no container is using right now, and a stopped database container counts as not using its volume. Recent Docker versions only remove anonymous volumes by default and need -a for named ones, older versions removed every unused volume; check docker volume prune --help before you rely on that. Treat both commands as "delete my databases" unless you have just checked docker volume ls and know what every entry is.

Also leave running builds alone. Pruning while docker build runs can remove a layer the build is about to use, and the error you get will not say so.

Why the disk doesn't shrink right away

Docker Desktop stores everything in a single file, Docker.raw, under ~/Library/Containers/com.docker.docker/Data/vms/0/data/. After a prune the space is free inside Docker's disk, but the file on your Mac only shrinks when Docker Desktop trims it, which happens periodically and on restart. If a build fails for lack of space while your Mac has room, the virtual disk limit under Settings, Resources is the ceiling: prune first, then raise it if needed. Troubleshoot, Clean / Purge data wipes the whole disk, volumes included.

OrbStack has no fixed limit and hands freed space back to macOS gradually, in the background. Finder lags behind for a while after a prune; that is normal.

Or let Sluice do it

Sluice, a menu bar disk cleaner for developer Macs, prunes the stale build cache and untagged images through the docker command, the same commands as above. It never touches volumes or containers, and waits while docker build runs. It works with Docker Desktop and OrbStack, and tells you when OrbStack is still handing the space back. Sluice is free to download and clean with; Pro cleans every night and whenever space runs low.

macOS 14 Sonoma or later · Apple silicon and Intel · or brew install --cask qraft/tap/sluice

FAQ

Does docker system prune delete volumes?

Not without --volumes. Plain docker system prune and docker system prune -a remove containers, networks, images and build cache, and leave every volume alone. Adding --volumes is the step that deletes data.

I pruned and my Mac still has the same free space. Why?

Docker Desktop keeps its data in one disk image that shrinks when Docker trims it, not the moment you prune. Give it a few minutes or restart Docker Desktop. With OrbStack the space comes back gradually. Inside Docker the space is already free: docker system df shows it.

How often should I prune the build cache?

Whenever docker system df shows more cache than you want to give up. docker builder prune without -a is the one to run routinely: it only takes cache no current build needs, so daily builds stay fast. Save -a and docker system prune -a for when you really need the room.