Docker No Space Left on Device — Disk Full from Images, Volumes, and Build Cache
About Docker No Space Left on Device
Fix Docker 'no space left on device' errors caused by accumulated images, stopped containers, unused volumes, and build cache filling up disk space. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: Docker stores images, containers, volumes, and build cache in /var/lib/docker by default. Unused images, stopped containers, and dangling volumes accumulate over time. Build cache from multi-stage builds and layer caching can consume significant space. Docker uses overlay2 filesystem by default which shares layers between images efficiently. The 'docker system df' command shows disk usage breakdown by type. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Old Docker images never cleaned up accumulating over months of pulls and builds. Stopped containers with large log files consuming disk space. Orphaned volumes from deleted containers still holding data. Docker build cache growing from frequent image builds without pruning. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Check Docker disk usage: 'docker system df -v' to see detailed usage by images, containers, volumes. Prune everything unused: 'docker system prune -a --volumes' (removes all unused images, containers, volumes, and networks). Prune selectively: 'docker image prune -a' (unused images), 'docker volume prune' (unused volumes), 'docker builder prune' (build cache). Remove specific large images: 'docker images --format "table {{.Repository}}\t{{.Size}}"' then 'docker rmi image-id'. Move Docker data directory to a larger disk: edit /etc/docker/daemon.json with '"data-root": "/new/path"'. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Is docker system prune safe?
docker system prune removes stopped containers, dangling images, and unused networks. With -a, it also removes all unused images (not just dangling). With --volumes, it removes unused volumes. It never removes running containers or their volumes.
Overview
Fix Docker 'no space left on device' errors caused by accumulated images, stopped containers, unused volumes, and build cache filling up disk space.
Key Details
- Docker stores images, containers, volumes, and build cache in /var/lib/docker by default
- Unused images, stopped containers, and dangling volumes accumulate over time
- Build cache from multi-stage builds and layer caching can consume significant space
- Docker uses overlay2 filesystem by default which shares layers between images efficiently
- The 'docker system df' command shows disk usage breakdown by type
Common Causes
- Old Docker images never cleaned up accumulating over months of pulls and builds
- Stopped containers with large log files consuming disk space
- Orphaned volumes from deleted containers still holding data
- Docker build cache growing from frequent image builds without pruning
Steps
- 1Check Docker disk usage: 'docker system df -v' to see detailed usage by images, containers, volumes
- 2Prune everything unused: 'docker system prune -a --volumes' (removes all unused images, containers, volumes, and networks)
- 3Prune selectively: 'docker image prune -a' (unused images), 'docker volume prune' (unused volumes), 'docker builder prune' (build cache)
- 4Remove specific large images: 'docker images --format "table {{.Repository}}\t{{.Size}}"' then 'docker rmi image-id'
- 5Move Docker data directory to a larger disk: edit /etc/docker/daemon.json with '"data-root": "/new/path"'