Docker Error
Docker Error: No Space Left on Device
Docker has run out of disk space — usually from accumulated unused images, stopped containers, and build cache, not the disk itself being full.
What This Error Means
This means Docker's storage area (images, containers, volumes, build cache — typically under /var/lib/docker on Linux) has consumed all available disk space, or the specific filesystem/partition Docker uses is full.
Why It Occurs
Docker accumulates unused images, stopped containers, dangling build layers, and unused volumes over time unless actively cleaned up — this is extremely common on development machines and CI runners that build images frequently without pruning.
Symptoms
- ⚠ Builds fail partway through with this error
- ⚠ Containers fail to start or write to disk
- ⚠ General disk-full symptoms elsewhere on the system too, if Docker shares the same partition
Common Causes
- • Accumulated unused/dangling images from repeated builds
- • Stopped containers never removed
- • Unused volumes accumulating data
- • Build cache growing unbounded over many builds
How to Fix It
- Check what Docker is actually using: `docker system df` — shows a breakdown of images, containers, volumes, and build cache size
- Remove unused data safely: `docker system prune` (removes stopped containers, unused networks, dangling images, and build cache — NOT volumes or running containers)
- For a more aggressive cleanup including unused (not just dangling) images: `docker system prune -a`
- To also remove unused volumes (check first — this can delete data you need): `docker system prune -a --volumes`
- Check overall disk usage on the host to confirm the fix actually freed meaningful space: `df -h`
| Command | Purpose |
|---|---|
| docker system df | See a breakdown of what's consuming Docker's disk space |
| docker system prune | Remove unused containers, networks, dangling images, and build cache (safe default) |
| docker system prune -a --volumes | Aggressive cleanup including unused images and volumes — verify you don't need any of it first |
Verification
- ✓ `df -h` shows meaningfully more free space after cleanup
- ✓ A previously-failing build now completes successfully
Prevention
- → Schedule regular `docker system prune` runs (e.g. a weekly cron job) on development machines and CI runners
- → Use multi-stage Docker builds to reduce final image size and intermediate layer accumulation