Docker "no space left on device" during build in CI
The build ran the runner out of disk. Almost always it is accumulated image layers and BuildKit cache, plus large base images, on a runner with a small disk.
What this error means
A build fails mid-step, often while extracting a layer or writing an artifact, with a kernel no space left on device. It can surface from build, pull, or a RUN that writes a large file.
docker
ERROR: failed to solve: failed to copy: write /var/lib/docker/...: no space left on deviceCommon causes
Accumulated cache and dangling layers
On long-lived runners the BuildKit cache and intermediate layers are never garbage-collected and fill the disk.
Large base images and multi-stage leftovers
Pulling several large base images in one job can exhaust a small disk before the build finishes.
Genuinely small runner disk
A default runner disk may simply be too small for an image-heavy build.
How to fix it
Reclaim space immediately
- Prune everything Docker no longer needs (safe in fresh CI).
Terminal
docker system prune --all --force --volumes
docker builder prune --all --forceFree space before the build
- Remove preinstalled toolchains you do not need at the start of the job.
- Add a .dockerignore so large local dirs are not sent to the context.
.github/workflows/build.yml
- name: Free disk
run: |
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android
df -hHow to prevent it
- Prune at the start of Docker jobs, keep a .dockerignore current, and size runners for image-heavy pipelines. Latchkey managed runners auto-retry transient disk-pressure failures and start jobs on clean disk, reducing carry-over from prior runs.
Related guides
Docker exit code 137 (OOM) during build in CIFix the Docker "exit code: 137" out-of-memory build error in CI, where the OOM killer terminates a RUN step t…
Docker "returned a non-zero code: 1" on a RUN step in CIFix the Docker "The command ... returned a non-zero code: 1" build error in CI, where a RUN instruction itsel…
Docker "toomanyrequests" Docker Hub rate limit in CIFix the Docker "toomanyrequests: You have reached your pull rate limit" Docker Hub error in CI by authenticat…