Fix "no space left on device" (Docker and Linux)
failed to register layer: Error processing tar file(exit status 1): write /usr/lib/x86_64-linux-gnu/libLLVM-17.so.1: no space left on device
- ERROR: failed to solve: failed to copy: write /var/lib/docker/buildkit/content/ingest/3b2f/data: no space left on device
- write /var/lib/docker/tmp/GetImageBlob123456789: no space left on device
- Error: ENOSPC: no space left on device, write
- OSError: [Errno 28] No space left on device
- cannot create temp file for here-document: No space left on device
The file system being written to is full, in space or in inodes. With Docker it is almost always images, build cache and logs in /var/lib/docker: check with df -h and docker system df, then clean up with docker builder prune and docker image prune -a.
What this error means
This is the ENOSPC system error: the kernel refuses a write because the target partition has no free blocks left, or no inodes left (the maximum number of files). Docker stores images, layers, BuildKit cache, volumes and container logs in /var/lib/docker on Linux, or in the Docker Desktop VM’s virtual disk on macOS and Windows. A docker pull or docker build extracting large layers fails as soon as that space runs out, even if your main disk seems to have room.
Common causes
- Accumulated images and build cache: every build leaves intermediate layers and
<none>(dangling) images. - Container logs without rotation: the
json-filedriver writes without limit to/var/lib/docker/containers/*/*-json.log. - Docker Desktop virtual disk full (macOS/Windows): the VM has a maximum size set in the settings.
- Inodes exhausted:
df -hshows free space, butdf -ishows 100% (millions of small files,node_modules, caches). - Small dedicated partition: a separate, too small
/varor/tmp(sometimes a RAMtmpfs), or large system journals.
Step-by-step fix
-
Find the full partition
Check space and inodes. Spot the line holding
/var/lib/docker(or/) at 100%.df -h df -i -
Measure what Docker uses
docker system dfbreaks down images, containers, volumes and build cache, with the reclaimable share (RECLAIMABLE).docker system df docker system df -v -
Clean up without touching data
These commands remove build cache, stopped containers and unused images. They do not touch volumes. Avoid
docker system prune -a --volumesunless you know what is inside:--volumesdeletes unused volumes, so your local databases.docker builder prune docker container prune docker image prune -a -
Empty and cap container logs (Linux)
Find large log files and empty them with
truncate(notrm, the file is still open). Then cap the size in/etc/docker/daemon.jsonand restart Docker; the rule applies to containers created afterwards.sudo sh -c 'du -h /var/lib/docker/containers/*/*-json.log | sort -h | tail -5' sudo truncate -s 0 /var/lib/docker/containers/<id>/<id>-json.log -
Configure log rotation
Content of
/etc/docker/daemon.json, thensudo systemctl restart dockerand recreate the containers (docker compose up -d --force-recreate).{ "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "3" } } -
Linux outside Docker: find what fills the disk
Find the largest folders on the partition, then free systemd journals and the package cache. On macOS, replace
--max-depth=1with-d 1.sudo du -xh / --max-depth=1 2>/dev/null | sort -h | tail -10 sudo journalctl --vacuum-size=200M sudo apt clean # Debian/Ubuntu -
macOS / Windows: grow the Docker Desktop disk
In Docker Desktop, open Settings > Resources > Advanced and raise the virtual disk limit, after the cleanup above. The Troubleshoot menu also offers "Clean / Purge data", which wipes all images and volumes: keep it as a last resort.
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Enable log rotation in
daemon.jsonas soon as a server is installed. - Schedule regular cleanup in CI and on runners:
docker builder prune --filter until=72h -fanddocker image prune -a --filter until=168h -f. - Use a
.dockerignore(node_modules,.git,vendor) and multi-stage builds to keep images small. - On a server, put Docker’s
data-rooton a dedicated disk and monitor it (alert at 80%).
Frequently asked questions
Does docker system prune delete my volumes?
Not by default. It removes stopped containers, unused networks, dangling images and build cache. Volumes are only removed with --volumes, and -a also removes every image not used by a container.
df -h shows free space but I get "no space left on device", why?
Inodes are probably exhausted: check with df -i. The write may also target another partition (/tmp, /var) or the Docker Desktop virtual disk.
Can I just delete /var/lib/docker?
Not while Docker is running, and only if you accept losing all images, containers and volumes. Prefer the prune commands, which keep a consistent state.
Useful tools for this error
More Docker & DevOps errors
- Fix "permission denied while trying to connect to the Docker daemon socket"
- Fix "Bind for 0.0.0.0:8080 failed: port is already allocated" (Docker)
- Fix "exec format error" in Docker (arm64 / amd64)
- Fix "Cannot connect to the Docker daemon. Is the docker daemon running?"
- Fix "connect() failed (111: Connection refused) while connecting to upstream" (Nginx 502)
- Fix "exited with code 137" (OOMKilled) in Docker and Kubernetes
- Fix "CrashLoopBackOff" / "Back-off restarting failed container" (Kubernetes)