No space left on device
The host or Docker virtual disk has run out of storage space, blocking builds, pulls, and container execution.
Usually happens because:
- ☑ Accumulated BuildKit builder cache
- ☑ Orphaned volumes and containers log data
- ☑ Virtual machine hard disk limit reached
🔍 Quick Checklist:
What is No space left on device?
This error occurs when the file system containing Docker's storage directory (usually /var/lib/docker or the virtual disk file allocated for Docker Desktop) runs out of available storage capacity. Over time, unused builder cache, dangling images, stopped containers, and volume logs accumulate, consuming hundreds of gigabytes until the engine can no longer write files.
Common Causes
- Accumulated Builder Cache: BuildKit builder cache accumulates from previous builds and is never pruned.
- Dangling Images and Volumes: Abandoned container images ('<none>:<none>') and orphan volumes left behind by retired services.
- Hypervisor VM disk size limit: Docker Desktop virtual disk (.raw or .vhdx) has reached its pre-allocated maximum disk size.
| Cause | Frequency |
|---|---|
| Accumulated BuildKit builder cache | ⭐⭐⭐⭐⭐ |
| Orphaned volume logs & images | ⭐⭐⭐⭐ |
| Hypervisor VM hard disk limit | ⭐⭐⭐ |
Common Mistakes
- Running `docker system prune` without the `--volumes` flag, which leaves large database volumes completely untouched.
- Neglecting to limit log sizes in docker-compose files, allowing log files to grow unchecked until the disk is full.
How to Fix
Docker Operations & Verification
Inspect how much storage is occupied by different Docker entities.
$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 24 5 12.4GB 8.2GB (66%)
Containers 10 2 1.2GB 1.1GB (91%)
Local Volumes 5 2 45.1GB 40.2GB (89%)
Build Cache 120 0 32.4GB 32.4GBPlatform Specific Fixes
Check host partition disk sizes and mount limits.
# Check partition free space
df -h /var/lib/docker
# Find large container log files
sudo du -sh /var/lib/docker/containers/*Best Practices
- Configure log rotation policies in your Docker daemon configs (`log-driver: json-file` with `max-size: 10m`).
- Regularly set up cron jobs to run system prunes in development servers.
Frequently Asked Questions (FAQ)
Q: Why does Docker say no space left on device?
The host partition or Docker virtual machine storage disk has hit 100% capacity, blocking any write operations.
Q: How do I find out what is taking up space?
Run 'docker system df' to inspect disk consumption divided by images, containers, local volumes, and build cache.
Q: How do I reclaim space in WSL2?
WSL2 virtual disks (.vhdx) do not automatically shrink. You must shut down WSL (`wsl --shutdown`) and shrink the disk using the Windows Diskpart tool or Optimize-VHD.
Q: What is the difference between system prune and volume prune?
'docker system prune' does not delete volumes by default to protect user database files. To delete volumes as well, you must explicitly run 'docker system prune --volumes' or run 'docker volume prune'.