docker build: "write error: no space left on device"
A docker build aborted because writing a layer hit ENOSPC. Each instruction can add a layer, and the build cache plus base images quickly fill a small runner disk.
What this error means
The build fails part-way through with write error: no space left on device, usually during a RUN, COPY, or layer export. A fresh runner or a prune clears it without any Dockerfile change.
=> ERROR [build 6/9] RUN npm ci
write /var/lib/docker/tmp/buildkit-...: no space left on device
##[error] buildx failed with: ERROR: failed to solve: no space left on deviceCommon causes
The build cache and image layers filled /var/lib/docker
BuildKit keeps a layer cache and intermediate state. Across jobs on a reused runner this grows until the docker data root is full.
Large base images or build context
A multi-GB base image or an unfiltered build context (missing .dockerignore) can exhaust the disk in a single build.
How to fix it
Prune docker data and shrink the context
Reclaim layer cache and dangling state, then trim what gets sent to the daemon.
docker system df
docker builder prune --all --force
docker system prune --all --force --volumesReduce what each build writes
- Add a
.dockerignoreto keepnode_modules,.git, and artifacts out of the build context. - Use multi-stage builds so only the final stage ships.
- Run image-heavy builds on a runner with a larger disk.
How to prevent it
- Prune the builder cache between heavy builds.
- Keep base images lean and pin them.
- Right-size disk for runners that build large images.