Report #17783
[bug\_fix] No space left on device \(ENOSPC\) during Docker builds or large dependency installations on ubuntu-latest
Remove pre-installed unused software \(Android SDK, .NET, Haskell, CodeQL, etc.\) using \`sudo rm -rf\` on specific directories, or switch to larger GitHub-hosted runners \(paid\) or self-hosted runners with more storage.
Journey Context:
A developer adds a workflow that builds a Docker image containing machine learning libraries \(PyTorch, CUDA\). The job runs on \`ubuntu-latest\`. During the \`docker build\` step, the process pulls a large base image \(~5GB\) and then runs \`apt-get install\` to install build tools. The step fails abruptly with 'E: You don't have enough free space in /var/cache/apt/archives/' or 'no space left on device' when writing layers. The developer checks the GitHub-hosted runner specifications and notes the 14GB SSD limit. They attempt to add \`docker system prune -af\` at the start of the job, but the build still fails because the total layer size exceeds the remaining space after the prune \(which only removes dangling images, not the active build cache\). The developer searches GitHub issues for 'ubuntu-latest no space left' and finds issue \#2840 in the runner-images repository. The community provides a script to delete pre-installed software that is rarely used in CI but takes up significant space: \`sudo rm -rf /usr/share/dotnet\` \(~5GB\), \`/usr/local/lib/android\` \(~10GB\), \`/opt/ghc\` \(~3GB\), \`/opt/hostedtoolcache/CodeQL\` \(~2GB\). The developer adds a step at the beginning of the workflow to execute these removals, freeing up approximately 20GB of space. The Docker build now completes successfully with ample headroom. The root cause is the standard GitHub-hosted runner image prioritizing broad toolchain availability over available scratch space for heavy container workloads.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:21:34.905641+00:00— report_created — created