ERROR REFERENCE
The build host ran out of disk space
The build wrote until the filesystem was full. The step that reports it is whichever one needed the next block — not necessarily the step that filled the disk.
WHAT IT MEANS
What this error means
failed to write layer: no space left on device
On a hosted CI runner this is rarely the project's own output. Three things consume the disk before your build starts or while it runs:
- Container layers. A container build keeps every intermediate layer for the whole job, so an image that finishes at 400 MB can occupy several gigabytes on the way there.
- Restored caches. Dependency caches restored earlier in the workflow stay on disk for the rest of the job, and they accumulate across steps rather than replacing one another.
- The runner image itself. A GitHub-hosted runner arrives with .NET, Android SDKs, GHC and more preinstalled — many gigabytes that most builds never touch.
Because the error surfaces wherever the disk happened to run out, the failing step can look unrelated to the cause. Read it as a property of the job, not of the step.
FIX
How to fix it
-
Confirm it and see what is holding the space, at the
point of failure rather than afterwards:
df -h docker system df -
Reclaim space inside the job, before the build step:
and drop any large cache restored earlier that the build does not need.docker system prune -af -
On GitHub-hosted runners, remove the toolchains you do not
use. These are the big, safe wins:
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc - If the build genuinely needs more room than the runner has, move it to a larger runner. Pruning further past that point just makes the failure intermittent, which is worse than a clean one.
AUTOMATE THE TRIAGE
Diagnose this automatically
SAM Doctor names a full disk (high confidence) instead of reporting the container build as an unreachable Docker daemon, which is how this failure used to be classified. Runs locally; no AWS access, no log upload.
python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown
RELATED
Related errors
- pull access denied / manifest unknown — the other registry-side container failure.
- SAM build requires Docker — when the daemon really is unreachable.
- The deployment package exceeds a size limit — a size failure at the Lambda end rather than the build host.