DevOpsil
github-actionsHigh

Fix: GitHub Actions Runner Disk Full During Build

Build fails with 'No space left on device'

!Symptoms

  • Build fails with 'No space left on device'
  • Docker build step fails during large layer creation
  • npm/pip install fails writing to disk
  • Artifact upload fails due to insufficient space

?Root Causes

  • GitHub-hosted runners have limited disk space (~14GB free)
  • Docker images and layers consuming space from previous steps
  • Large build artifacts or dependencies filling the disk
  • Multiple Docker builds without intermediate cleanup
  • Node modules or Python virtualenvs consuming excessive space

#Diagnosis Steps

  1. 1Add `df -h` step before the failing step to see disk usage
  2. 2Check Docker space: add `docker system df` step
  3. 3Check which directory is largest: `du -sh /home/runner/work/*`
  4. 4Review previous steps for large downloads or builds
  5. 5Check if caching is storing too much data

>Fix

  1. 1Free space by removing unused software: `sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc`
  2. 2Clean Docker between steps: `docker system prune -af`
  3. 3Use `actions/cache` with proper key rotation to avoid stale caches
  4. 4Split the workflow into multiple jobs that run on fresh runners
  5. 5Use multi-stage Docker builds to reduce layer sizes

*Prevention

  • Add a disk space check step at the start of workflows
  • Use larger runners (GitHub-hosted or self-hosted) for big builds
  • Implement Docker layer caching with `docker/build-push-action`
  • Clean up intermediate artifacts between build steps
  • Use .dockerignore and .npmrc to minimize what gets copied/installed

Related Error Messages

No space left on deviceENOSPC: no space left on devicewrite /tmp/: no space left on devicecannot create temp file for here-document