SAM Doctor

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:

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

  1. Confirm it and see what is holding the space, at the point of failure rather than afterwards:
    df -h
    docker system df
  2. Reclaim space inside the job, before the build step:
    docker system prune -af
    and drop any large cache restored earlier that the build does not need.
  3. 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
  4. 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