How to Fix Docker No Space Left on Device Errors Without Just Deleting Random Images and Hoping the Disk Forgives You
A practical guide to fixing Docker no space left on device errors by measuring image, container, build cache, and volume usage first, then pruning the right layers instead of blindly nuking useful state.
Why this failure gets messy: Docker can fill a machine gradually through old images, stopped containers, layers, build cache, and volumes, which means random cleanup often removes the wrong thing first.
Typical errors:
no space left on deviceor builds failing partway through writes.
Step 1: measure before deleting
Start here:
docker system df
docker image ls
docker volume lsThis tells you whether the bulk is in:
- images
- containers
- local volumes
- build cache
Step 2: remove clearly disposable layers
Unused images:
docker image prune -aStopped containers:
docker container pruneUnused build cache:
docker builder pruneBe deliberate. -a is powerful. Do not run it while assuming every image can be re-pulled cheaply in your environment.
Step 3: inspect volumes carefully
Volumes can hide the largest forgotten data sets.
docker volume pruneBut only after you know those volumes are disposable. Databases and local app state often live there.
Step 4: rebuild with less churn
If the machine keeps filling up, the real fix may be reducing rebuild waste:
- smaller base images
- better layer caching
- fewer redundant local environments
- scheduled cleanup
Quick recovery path
If you need fast relief and understand the impact:
docker system pruneFor a more aggressive cleanup:
docker system prune -aBottom line
No space left on device in Docker is a storage accounting problem, not a mystical daemon curse. Measure first, then prune the specific layer types creating the pressure.