no space left on device
ID: docker/no-space-left
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 24 | active | — | — | — |
| 24 | active | — | — | — |
Root Cause
Docker 'no space left on device' on Linux is caused by accumulated images, containers, volumes, and build cache consuming disk space in /var/lib/docker. The fix involves pruning unused Docker objects and potentially moving the Docker data root to a larger partition.
genericWorkarounds
-
90% success Run a comprehensive Docker prune including volumes
docker system prune -a --volumes --force. The '-a' flag removes all unused images (not just dangling ones), and '--volumes' removes unused volumes. Warning: this removes ALL data in unnamed volumes. Verify no important data is in volumes first with 'docker volume ls'.
Sources: https://docs.docker.com/reference/cli/docker/system/prune/
-
85% success Move Docker's data root to a larger partition
Stop Docker: 'sudo systemctl stop docker'. Edit /etc/docker/daemon.json and add: {"data-root": "/mnt/large-disk/docker"}. Copy existing data: 'sudo rsync -aP /var/lib/docker/ /mnt/large-disk/docker/'. Start Docker: 'sudo systemctl start docker'. Verify with 'docker info | grep Root'.Sources: https://docs.docker.com/engine/daemon/#daemon-data-directory
-
80% success Set up automatic pruning with a cron job or Docker's built-in log rotation
Add to crontab: '0 2 * * 0 docker system prune -af --filter "until=168h"' (weekly prune of resources older than 7 days). For log rotation, add to /etc/docker/daemon.json: {"log-driver": "json-file", "log-opts": {"max-size": "10m", "max-file": "3"}}.
Dead Ends
Common approaches that don't work:
-
Running 'docker system prune' without the --volumes flag
55% fail
The default 'docker system prune' does NOT remove volumes. Docker volumes often consume the most space (databases, application data) and are the primary cause of disk exhaustion. Without --volumes, the prune may free little space.
-
Manually deleting files from /var/lib/docker
90% fail
The /var/lib/docker directory has a complex internal structure managed by Docker's storage drivers (overlay2, btrfs, etc.). Manually deleting files corrupts Docker's internal state, leading to broken containers, orphaned layers, and potentially an unrecoverable Docker installation.