Introduction CI/CD runners that run out of disk space fail all builds. This is especially common with self-hosted runners that accumulate Docker images, build artifacts, and workspace files over time.
Symptoms - Build fails with: "No space left on device" - Error: "failed to write: no space left on device" - Docker build fails: "overlay2: no space left on device" - Runner shows 100% disk usage in monitoring - Builds fail intermittently based on runner selection
Common Causes - Docker images not pruned between builds - Build artifacts accumulating in workspace - npm/pip/maven caches growing unbounded - Git repository clones accumulating (bare repos) - Core dump files from crashed processes
Step-by-Step Fix 1. **Check disk usage on the runner**: ```bash df -h du -sh /home/runner/work/* | sort -rh | head -10 docker system df ```
- 1.Clean up Docker images:
- 2.```bash
- 3.docker system prune -af --volumes
- 4.docker image prune -af
- 5.
` - 6.Clean up workspace directories:
- 7.```bash
- 8.# GitHub Actions
- 9.rm -rf /home/runner/work/*
- 10.# GitLab CI
- 11.rm -rf /builds/*
- 12.
` - 13.Add cleanup step to pipeline:
- 14.```yaml
- 15.# GitHub Actions
- 16.- name: Cleanup
- 17.if: always()
- 18.run: |
- 19.docker system prune -af
- 20.rm -rf $GITHUB_WORKSPACE/*
- 21.
`