docker no space left on device — how to fix
Quick Answer
# See how much Docker is using
docker system df
# Remove all stopped containers, unused images, networks, build cache
docker system prune -a
# Also remove unused volumes (data loss risk — check first)
docker system prune -a --volumes
When this happens
ERROR: failed to solve: failed to prepare ...:
write /var/lib/docker/tmp/...: no space left on device
Docker has exhausted disk space. Unused images, stopped containers, and build cache accumulate over time.
Other causes & fixes
Prune selectively (safer)
# Only dangling (untagged) images
docker image prune
# Only stopped containers
docker container prune
# Only build cache
docker builder prune
# Only unused volumes
docker volume prune
Find large images
docker images --format "{{.Repository}}:{{.Tag}}\t{{.Size}}" | sort -k2 -h -r | head -20
Move Docker data directory (Linux)
If the root partition is small, move Docker data to a larger disk.
# /etc/docker/daemon.json
{
"data-root": "/mnt/docker-data"
}
# Then: sudo systemctl restart docker
Related