Skip to content
Latchkey

Jenkins Agent "No space left on device" - Fix Disk Exhaustion

A step could not write because the agent’s disk is full. Workspaces, Docker images/layers, and old build data accumulate until a write fails with ENOSPC, killing the build partway through.

What this error means

A build fails with No space left on device (or write error: No space left on device) during checkout, build, or a Docker step. df -h on the agent shows the workspace or Docker volume at or near 100%.

Jenkins console
fatal: write error: No space left on device
# or from a Docker build
failed to copy files: write /var/lib/docker/...: no space left on device

Common causes

Workspaces and old builds not cleaned

Many jobs leave large workspaces, and undiscarded build history/artifacts accumulate on the agent and controller until the disk fills.

Docker images and layers piling up

Repeated docker build/pull on a long-lived agent fills /var/lib/docker with dangling images, layers, and build cache that nothing prunes.

How to fix it

Clean the workspace and prune Docker

Free space as part of the pipeline or on the agent host.

Jenkinsfile
cleanWs()                 // Workspace Cleanup plugin, in post {}
sh 'docker system prune -af --volumes'   // reclaim image/layer/cache space

Bound retention and use ephemeral agents

  1. Add "Discard old builds" so artifacts/logs do not accumulate indefinitely.
  2. Run builds on ephemeral (container/cloud) agents that start with a clean disk.
  3. Schedule docker system prune and stale-workspace cleanup on persistent agents.

How to prevent it

  • Add cleanWs() and "Discard old builds" to every heavy job.
  • Prefer ephemeral agents so disk never accumulates across builds.
  • Monitor agent disk and prune Docker on a schedule.

Frequently asked questions

What causes ""No space left on device""?
Many jobs leave large workspaces, and undiscarded build history/artifacts accumulate on the agent and controller until the disk fills.
How do I fix "No space left on device"?
Free space as part of the pipeline or on the agent host.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card