A build or container start suddenly fails with:
failed to register layer: write /usr/lib/x86_64-linux-gnu/libLLVM.so: no space left on device
On CI agents and long-running hosts this is one of the most common Docker problems. Here's how to free space without deleting anything you need.
What the error means
The filesystem holding Docker's data (usually /var/lib/docker) is full, either out of bytes or out of inodes. Check both:
df -h /var/lib/docker
df -i /var/lib/docker
Then see what Docker itself is using:
docker system df
docker system df -v # per image, container and volume
How to fix it, step by step
1. Remove stopped containers
docker container prune
2. Remove unused images
# only dangling (untagged) images
docker image prune
# all images not used by any container (they will be re-pulled when needed)
docker image prune -a
# only images older than 3 days
docker image prune -a --filter "until=72h"
3. Clear the build cache
BuildKit cache is often the biggest item on build servers:
docker builder prune
docker builder prune --filter "until=72h"
4. Check volumes carefully
Volumes can hold real data (databases, uploads). List them first, then remove only what you're sure is unused:
docker volume ls -f dangling=true
docker volume prune
5. Find and cap huge container logs
With the default json-file log driver, logs grow forever:
sudo find /var/lib/docker/containers -name "*-json.log" -size +100M -exec ls -lh {} \;
Limit them for all new containers in /etc/docker/daemon.json:
{
"log-driver": "json-file",
"log-opts": { "max-size": "10m", "max-file": "3" }
}
sudo systemctl restart docker
Existing containers keep their old settings until they're recreated.
6. Everything at once (use with care)
docker system prune -a --volumes
This deletes all stopped containers, unused networks, all unused images, build cache and unused volumes. Fine on a disposable CI agent; dangerous on a server with data in volumes.
7. Move Docker's data to a bigger disk
If the root disk is simply too small, set "data-root": "/data/docker" in daemon.json, stop Docker, copy the old directory across and restart.
How to prevent it
- Schedule cleanup on CI agents, e.g. a nightly
docker system prune -af --filter "until=72h". - Cap container logs in
daemon.jsonon every host. - Use multi-stage builds and small base images so images stay small.
- Alert on disk usage with Prometheus and Grafana before it reaches 100%.
Image optimisation, multi-stage builds and registry management are part of our Docker & Kubernetes training.
Frequently asked questions
Is docker system prune safe?
docker system prune removes stopped containers, unused networks, dangling images and build cache, which is usually safe. Adding -a also removes all unused images, and --volumes deletes unused volumes, which can contain data, so use those flags carefully.
Why is /var/lib/docker so large?
It stores images, container layers, build cache, volumes and container log files. Large JSON log files from chatty containers are a common hidden cause.
How do I stop Docker logs from filling the disk?
Set the json-file log driver options max-size and max-file in /etc/docker/daemon.json, then restart Docker. New containers will rotate their logs automatically.
Learn Docker, Kubernetes & OpenShift hands-on with expert trainers
Fixing problems like this one is part of our Docker, Kubernetes & OpenShift training: live online classes for individuals and on-site corporate training for teams, with real projects and labs.
Training available in Hyderabad, Bangalore, Pune, Mumbai, Delhi, Chennai and online across India.