Docker: No Space Left on Device

A build or pull dies with 'no space left on device', but df says you have room. Docker hoards old images, stopped containers, and volumes. Here's how to find and reclaim the space safely.

BytExplorer 5 min read July 1, 2026

Your build stops dead:

write /var/lib/docker/...: no space left on device

Nine times out of ten your disk isn't actually full of your files — it's full of Docker's leftovers. Every image layer, stopped container, and unused volume you've ever created is sitting in /var/lib/docker until you clean it up.

Step 1: See what Docker is holding

Before deleting anything, look at where the space went:

docker system df        # summary: images, containers, volumes, build cache
df -h /var/lib/docker   # confirm the underlying filesystem is the full one

docker system df breaks it down by type and shows a RECLAIMABLE column — that's your target.

Step 2: Prune the safe stuff first

Start with dangling images and stopped containers — nothing you're using loses data:

docker container prune   # remove stopped containers
docker image prune       # remove dangling (untagged) images

Step 3: The bigger sweep

If you need more room, prune everything unused in one shot:

docker system prune -a    # removes ALL images not used by a running container

-a is aggressive: it deletes every image without a running container, so the next build re-pulls base images. Great for reclaiming gigabytes, but expect the next build to be slower.

Watch out: volumes hold your data

docker system prune -a does not touch named volumes by default — that's deliberate, because volumes usually hold databases. Only add --volumes if you're certain nothing important lives there:

docker volume ls                 # look before you leap
docker volume prune              # removes volumes not attached to any container

Build cache is often the real hog

On machines that build a lot, the BuildKit cache balloons:

docker builder prune             # clear build cache specifically

The checklist

  1. docker system df — find the reclaimable space.
  2. docker container prune + docker image prune — safe wins first.
  3. docker system prune -a — bigger sweep (re-pulls later).
  4. docker builder prune — if build cache is the culprit.
  5. Only touch docker volume prune after checking docker volume ls.
Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Troubleshooting