Skip to content
Latchkey

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 device

Common 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

  1. Prune everything Docker no longer needs (safe in fresh CI).
Terminal
docker system prune --all --force --volumes
docker builder prune --all --force

Free space before the build

  1. Remove preinstalled toolchains you do not need at the start of the job.
  2. 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 -h

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →