Run docker system df to see how much space images, containers, volumes and build cache use. docker system prune removes stopped containers, unused networks, dangling images and build cache; add -a to remove all unused images. Volumes hold data and are only removed with --volumes — check them before pruning. Container logs in /var/lib/docker/containers are another common cause; cap them with log-opts.
Symptoms
- /var/lib/docker takes most of the disk
- Builds fail with “no space left on device”
- df shows the root filesystem filling over weeks
How to diagnose it
See Docker’s usage
RECLAIMABLE shows what pruning could free. -v gives per-item detail.
docker system df docker system df -vFind large container logs
JSON log files grow without limit by default.
sudo du -h /var/lib/docker/containers/*/*-json.log | sort -rh | headList volumes not used by any container
Inspect before deleting; these may hold database data.
docker volume ls -f dangling=true
Common causes and fixes
Old images and build cache
Prune unused data. -a also removes images not used by a running or stopped container.
docker system prune
docker image prune -a
docker builder pruneUnlimited container logs
Cap logs for all new containers in /etc/docker/daemon.json, then restart Docker and recreate containers.
{
"log-driver": "json-file",
"log-opts": { "max-size": "10m", "max-file": "3" }
}Orphaned volumes
Remove only volumes you have confirmed are unused.
docker volume rm VOLUMEData written inside containers instead of volumes
Large writable layers show in docker ps -s. Move that data to a volume or bind mount.
Prevent it happening again
- Alert when DISK_used is above 85%.
- Set log-opts max-size in daemon.json on every Docker host.
- Schedule docker image prune in CI runners and build servers.
Set it up: Docker monitoring.
FAQ
Is docker system prune safe?
It does not touch running containers or volumes unless you add --volumes. It removes stopped containers, so restart anything you still need first.
Where does Docker store data?
/var/lib/docker by default; set data-root in daemon.json to move it.
Related guides
Get alerted before this becomes an outage.
Install the agent in one line. Statance watches CPU, memory, disk and services, and its AI assistant helps find the cause.