Troubleshooting guide
Docker "no space left on device": how to free disk space
Docker keeps images, build cache, volumes and logs until told otherwise. On a busy host they eventually fill the disk.
3 min read10 sectionsUpdated
On this page
# Overall filesystem, and inodes
df -h /var/lib/docker
df -i /var/lib/docker
# Docker's own breakdown
docker system df -v | head -40
# Largest container logs
sudo sh -c 'du -h /var/lib/docker/containers/*/*-json.log | sort -h | tail -5'Fixes
Start with the safe, reclaimable items:
docker builder prune -af removes build cache. docker image prune -a removes images not used by any container.
Warning: docker system prune --volumes and docker volume prune can delete database data. List volumes and check each one before removing anything.
Cap logs in /etc/docker/daemon.json with "log-opts": {"max-size": "50m", "max-file": "3"} and restart Docker. That applies to new containers. Move data-root to a larger disk if the host is simply too small.
On CI runners
Build hosts fill up quickly because each commit creates new layers. Schedule a cleanup that keeps recent cache, for example docker builder prune --keep-storage 20GB -f, instead of removing everything and paying for full rebuilds. Multi-stage builds keep final images small, and a good .dockerignore stops node_modules and build output from being sent into the build context.
Catch it automatically
Alert at 80 percent and at 90 percent of disk and of inodes, and use a rate-of-change alert that predicts when the disk will be full. Infrastructure monitoring shows the trend across hosts. Ship logs to central log management, so nodes do not need to retain them.
Is docker system prune safe?
Without --volumes, it removes stopped containers, unused networks, dangling images and cache. It does not remove named volumes, but stopped containers are lost.
Why is the disk full when images are small?
Container logs and build cache are commonly the bigger consumers.
Will log limits affect running containers?
No. They apply when a container is created, so recreate existing ones.
Related reading
- Error: connect ECONNREFUSED: What connect ECONNREFUSED means and why it happens with databases, Redis and APIs, especially in Docker where localhost is the container.
- What is full-stack monitoring?: Full-stack monitoring explained: covering browser, network, application, database and infrastructure, linked so one alert leads to the cause.
- Cloudflare error 525: SSL handshake failed: Fix Cloudflare error 525 SSL handshake failed: origin with no certificate, disabled SNI, cipher mismatches and Full mode, with openssl tests against the origin.
- ERR_CACHE_MISS: how to fix it: Fix ERR_CACHE_MISS ("Confirm Form Resubmission"): going back after a POST, cache settings, extensions, and how developers use Post/Redirect/Get.
- Cloudflare error 526: invalid SSL certificate: Fix Cloudflare error 526 Invalid SSL certificate in Full (strict) mode: expired origin certificates, self-signed certs, name mismatches and missing chains.
- Exit code 137: what it means in Docker and Kubernetes: Exit code 137 means a container received SIGKILL. Learn to tell memory limits from slow shutdowns and manual kills, with Docker and Kubernetes commands.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.