The Docker "no space left on device" error means the filesystem that holds Docker's data (usually /var/lib/docker, and on Docker Engine 29+ fresh installs also /var/lib/containerd) or the Docker Desktop virtual disk is full. To fix docker no space left on device errors, measure first with docker system df -v and df -h, then reclaim space in a safe order: stopped containers, unused images, build cache, and only then volumes, before adding log rotation so it does not come back.
This guide walks through that order with exact commands, explains the flags that changed in recent Docker releases (volume pruning since Docker 23, BuildKit's --reserved-space family, the containerd image store that became the default in Docker Engine 29), and covers Docker Desktop, CI runners and prevention. Everything below was checked against docs.docker.com as of November 2026, when the current Engine release is 29.10.1.
Why Docker No Space Left on Device Errors Happen
The message comes from the kernel (ENOSPC), not from Docker. Docker hits it when it tries to write a layer, extract an image, create a container's writable layer, append to a log file, or write build cache. Three different things can be "full":
- Disk blocks on the partition holding Docker's data root. This is the common case.
- Inodes on that partition. Images with huge numbers of tiny files (think
node_modules) can exhaust inodes whiledf -hstill shows free gigabytes. - The Docker Desktop VM disk on macOS and Windows. Your Mac can have 200 GB free while the Linux VM inside Docker Desktop has hit its own disk limit.
The fix depends on which one you hit, so diagnose before you delete anything.
Step 1: Diagnose Where the Space Went
Start with the host filesystem and inodes:
df -h /var/lib/docker /var/lib/containerd 2>/dev/null
df -i /var/lib/docker
If df -i shows 100% IUse%, you have an inode problem, and pruning many small images or build cache entries is the cure rather than deleting one big file.
Next, ask Docker what it thinks it is using. docker system df prints a summary with TYPE, TOTAL, ACTIVE, SIZE and RECLAIMABLE columns for images, containers, local volumes and build cache. Add -v for a per-object breakdown:
docker system df
docker system df -v
The RECLAIMABLE column is the important one: it is space held by objects that no running container needs. If build cache shows tens of gigabytes reclaimable, that is your quickest win.
Docker's own accounting does not include everything. Container logs, for example, are not reported as a separate line. To see the raw picture, measure the directories directly:
sudo du -xh --max-depth=1 /var/lib/docker | sort -h | tail -n 15
sudo du -xh --max-depth=1 /var/lib/containerd 2>/dev/null | sort -h | tail -n 10
sudo find /var/lib/docker/containers -name '*-json.log' -size +500M -exec ls -lh {} \;
Typical findings:
| Directory | What lives there | Usual culprit |
|---|---|---|
/var/lib/docker/overlay2 |
Image layers and container writable layers (legacy storage driver) | Old images, containers writing to their own filesystem |
/var/lib/containerd |
Image content and snapshots with the containerd image store | Same as above on Engine 29+ fresh installs |
/var/lib/docker/containers |
Per-container config and *-json.log files |
Unrotated logs |
/var/lib/docker/volumes |
Named and anonymous volumes | Database volumes, forgotten anonymous volumes |
/var/lib/docker/buildkit |
BuildKit cache | CI builds with no cache limit |
Check Which Image Store You Are Using
This matters more than it used to. Docker Engine 29.0 (released 2025-11-10) made the containerd image store the default for fresh installs; upgraded hosts keep the legacy overlay2 storage until you switch. According to the daemon configuration docs, with the containerd store "image contents and container snapshots are stored in /var/lib/containerd", while volumes and configs stay in /var/lib/docker. So du /var/lib/docker alone can badly under-report.
docker info -f '{{ .DriverStatus }}'
If the output contains io.containerd.snapshotter.v1, you are on the containerd store. The containerd store documentation also notes that it uses more disk for the same images than the old drivers, because it keeps the compressed layers as pulled and also the extracted snapshots. Budget for that when sizing disks.
Step 2: Free Up Space Safely, in This Order
The order below goes from "zero risk" to "can destroy data". Stop as soon as you have enough headroom.
1. Remove Stopped Containers
docker container ls -a --filter status=exited --filter status=created
docker container prune
docker container prune --filter "until=24h"
Stopped containers hold their writable layer and their logs. Removing them is safe unless you planned to docker start them again or copy files out of them.
2. Remove Unused Images
By default docker image prune removes only dangling images (untagged layers left behind by rebuilds). Add -a to remove every image that no container references:
docker image prune
docker image prune -a --filter "until=240h"
The until filter keeps anything created in the last 10 days, which protects images you pulled recently but have not run yet. Expect slower next pulls; nothing else breaks.
3. Trim the Build Cache
On build-heavy machines the BuildKit cache is often the largest consumer. There are two related commands, and their flags differ:
# Classic builder command: remove dangling cache, or all of it with -a
docker builder prune
docker builder prune -a --filter "until=72h"
# buildx: prune down to a size budget instead of wiping everything
docker buildx prune --max-used-space 20GB
docker buildx prune --reserved-space 10GB --min-free-space 30GB
The current docker buildx prune reference lists --max-used-space ("Maximum amount of disk space allowed to keep for cache"), --reserved-space ("Amount of disk space always allowed to keep for cache") and --min-free-space ("Target amount of free disk space after pruning"). The older --keep-storage flag is still listed on the docker builder prune page, but the Engine API renamed the underlying parameter, so on current tooling prefer the buildx flags. Size-based pruning is the better habit for CI hosts: you keep a warm cache and cap its growth instead of rebuilding from scratch every time.
4. Remove Unused Networks
Networks take almost no disk, but docker network prune is harmless and keeps docker system prune output honest.
5. Volumes, Carefully
This is where people lose databases. Since API 1.42 (Docker 23.0), docker volume prune "only removes anonymous volumes" by default. Named volumes, such as pgdata in your Compose file, survive unless you pass --all / -a:
docker volume ls --filter dangling=true
docker volume prune # anonymous, unused volumes only
docker volume prune --all # ALSO unused named volumes: read the list first
"Unused" means no container, running or stopped, references the volume. If you ran docker compose down earlier, your database volume is unused right now, and --all will delete it. Inspect before you prune:
docker volume ls -q --filter dangling=true | xargs -r docker volume inspect --format '{{ .Name }} {{ .Mountpoint }} {{ .Labels }}'
The One-Liner, and Why It Comes Last
docker system prune bundles steps 1 to 4: stopped containers, unused networks, dangling images and unused build cache. -a extends it to all unused images; --volumes adds anonymous volumes only, not named ones.
docker system prune
docker system prune -a --volumes --filter "until=72h"
It is fine on a laptop or a disposable CI runner. On a server, the step-by-step version lets you see what you are deleting.
Step 3: Fix Container Logs That Fill the Disk
A single chatty container can write tens of gigabytes of JSON logs. Docker's logging configuration page is explicit: the default driver is json-file, and "by default, no log-rotation is performed." For json-file, max-size defaults to -1 (unlimited) and max-file to 1.
First, find out which driver a container uses and how big its log is:
docker inspect -f '{{.HostConfig.LogConfig.Type}}' my-app
sudo ls -lh "$(docker inspect -f '{{.LogPath}}' my-app)"
For immediate relief on a log that is already huge, truncate it in place rather than deleting it (the daemon keeps the file handle open, so rm does not free the space until the container restarts):
sudo truncate -s 0 "$(docker inspect -f '{{.LogPath}}' my-app)"
Then set rotation globally in /etc/docker/daemon.json. Values must be strings:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
Alternatively switch to the local driver, which the docs recommend for most setups because it rotates by default: 20 MB per file, five files, compressed. The catch with either change: it applies only to new containers. Existing containers keep their old log config until you recreate them (docker compose up -d --force-recreate for Compose stacks). If you paste the JSON from a wiki, run it through a JSON formatter before restarting the daemon; a stray comma stops dockerd from starting.
Step 4: Move Docker's Data Root to a Bigger Disk
If the partition is simply too small, move the data. The data-root key in daemon.json controls where Docker stores data (/var/lib/docker on Linux, C:\ProgramData\docker on Windows):
sudo systemctl stop docker docker.socket
sudo rsync -aHAX --info=progress2 /var/lib/docker/ /mnt/docker-data/
echo '{ "data-root": "/mnt/docker-data" }' | sudo tee /etc/docker/daemon.json
sudo systemctl start docker
docker info -f '{{ .DockerRootDir }}'
Merge the key into your existing daemon.json rather than overwriting it if you already have log options there. Keep the old directory until you have verified that images, containers and volumes appear correctly, then delete it.
On Engine 29+ fresh installs, there is a second move to make. The daemon docs state that data-root does not change the containerd location; set the root value in /etc/containerd/config.toml and restart containerd as well. Forgetting this is the most common reason a "moved" Docker install still fills the root partition.
Docker Desktop on macOS and Windows
On Docker Desktop, everything lives inside a Linux VM disk image, so host-side du on your projects tells you nothing. Open Settings > Resources > Advanced: the settings reference describes a disk usage limit ("the maximum amount of disk space the engine can use") and the disk image location, which you can move to another drive.
Three practical points:
- Raise the limit or prune inside the VM. "No space left on device" inside Desktop usually means the VM disk limit was reached. Run the same prune commands; they operate inside the VM.
- The file on your Mac may look bigger than it is. The Mac FAQ explains that
Docker.rawis a sparse file; Finder may report its maximum size.ls -klsh Docker.rawshows actual consumption in the first column, and space freed inside the VM returns to macOS within seconds for the raw format. - Watch the containerd switch in Desktop 4.100. The Docker Desktop 4.100.1 release notes list a known issue: on update, installs that never enabled the containerd image store are switched to it, and existing images and containers appear hidden, "not deleted". Hidden images still occupy the VM disk. If you suddenly see an empty
docker imageslist and a full disk, go to Settings > General, clear "Use containerd for pulling and storing images", prune what you no longer need from the old store, then switch back.
Cleaning Up CI Runners
CI is where Docker disk problems are most predictable, because every pipeline pulls images and writes build cache.
On ephemeral hosted runners the disk is thrown away after each job, so the problem is a single job running out of space mid-build. Prune early in the job and avoid exporting layers you do not need:
- name: Free Docker disk space
run: |
df -h /
docker system prune -af
docker builder prune -af
df -h /
Many teams also delete preinstalled toolchains they do not use on hosted Ubuntu images. That works, but check the runner image documentation for current paths before hard-coding rm -rf lines, because image contents change. If you are weighing hosted against self-hosted runners for cost reasons, our GitHub Actions pricing breakdown covers the trade-offs.
On self-hosted runners the disk persists, so make cleanup a scheduled job instead of a firefight. A systemd timer or cron entry like this keeps a week of images and caps build cache:
# /etc/cron.daily/docker-cleanup
#!/bin/sh
docker container prune -f --filter "until=24h"
docker image prune -af --filter "until=168h"
docker buildx prune -f --max-used-space 50GB
You can also cap BuildKit permanently. The build garbage collection docs show this daemon.json setting for the default builder:
{
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
}
}
For standalone BuildKit (buildkitd.toml) the documented knobs are reservedSpace, maxUsedSpace and minFreeSpace; by default BuildKit keeps at most 60% of the disk or 100 GB, whichever is lower.
Prevention Checklist
Once you have headroom again, make sure you never see docker no space left on device in the middle of a deploy:
- Rotate logs with the
localdriver orjson-fileplusmax-size/max-file, and recreate existing containers so the setting applies. - Cap build cache with
builder.gcindaemon.jsonor scheduleddocker buildx prune --max-used-space. - Put Docker on its own partition or volume. A full
/var/lib/dockerthen cannot take down SSH, journald and the package manager with it. Move bothdata-rootand containerd'srooton Engine 29+. - Write to volumes, not the container filesystem. Apps that write caches or uploads into their own writable layer grow
overlay2/snapshots invisibly; mount a volume ortmpfsinstead. - Use multi-stage builds and
.dockerignore. Smaller images mean less disk on every host that pulls them. - Alert on disk usage at 80% for the Docker partition, and on inode usage, not just bytes.
- Review named volumes quarterly.
docker volume lswith labels tells you which project owns what; abandoned database volumes are common on shared dev servers.
If your pipelines build images with Dagger or BuildKit-heavy workflows, the cache settings above matter even more; our Dagger vs GitHub Actions comparison covers how each one caches. And if the host is due for an OS upgrade anyway, do the partition work during the Ubuntu 24.04 to 26.04 upgrade rather than as a separate maintenance window.
Frequently Asked Questions
Is it safe to run docker system prune -a?
It removes stopped containers, unused networks, all images not used by a container, and unused build cache. It does not touch volumes unless you add --volumes, and even then only anonymous volumes. The risk is losing stopped containers you meant to restart and having to re-pull images. On production servers, run the individual prune commands so you can review each list.
Why didn't docker volume prune free any space?
Since Docker 23.0 (API 1.42), docker volume prune only removes anonymous volumes. Unused named volumes, which is what Compose creates, need docker volume prune --all. Check docker volume ls --filter dangling=true first, because --all deletes named database volumes that no container currently references.
Why does /var/lib/docker look small but my disk is still full?
On Docker Engine 29 and later fresh installs, the containerd image store keeps image content and snapshots in /var/lib/containerd, not /var/lib/docker. Run docker info -f '{{ .DriverStatus }}' to confirm, and measure both directories. Also check for deleted-but-open log files with sudo lsof +L1.
How do I clear Docker build cache without losing all of it?
Use size-based pruning: docker buildx prune --max-used-space 20GB trims the cache down to a budget, keeping the most useful entries. docker builder prune -a removes all of it, which forces cold builds afterwards.
Does changing log-opts in daemon.json affect running containers?
No. Log settings in daemon.json apply to containers created after the daemon restarts. Recreate existing containers, for example with docker compose up -d --force-recreate, to pick up the new rotation settings.
Conclusion
Docker no space left on device is almost always one of five things: unrotated logs, piles of unused images, an uncapped build cache, forgotten volumes, or a Docker Desktop VM disk limit. Measure with docker system df -v, df -h and du across both /var/lib/docker and, on Engine 29+, /var/lib/containerd. Clean up in order from containers to images to build cache, treat volume prune --all as a deliberate decision, then add log rotation, a build-cache cap and a dedicated partition so the next full disk is an alert rather than an outage.