Skip to content
Latchkey

Docker build "failed to export image" in CI

All build steps ran, but BuildKit could not write the finished image in its export phase. The most common cause is the disk filling while committing layers; a corrupt or missing snapshot can also break the export.

What this error means

The build completes its steps, then fails with "ERROR: failed to solve: failed to export image" often ending in "no space left on device" or a layer error.

docker build
ERROR: failed to solve: failed to export image: failed to create image: failed to get layer
sha256:...: write /var/lib/docker/...: no space left on device

Common causes

Disk exhaustion during layer commit

The export phase writes layers to /var/lib/docker; if the disk fills there, the commit fails with "no space left on device".

A missing or corrupt snapshot

A broken snapshotter state means BuildKit cannot read a layer it needs to assemble the final image.

How to fix it

Free disk before the export

Reclaim space from old images, containers, and build cache so the export can complete.

Terminal
docker system prune -af --volumes
docker builder prune -af

Grow the build disk or reduce image size

  1. Increase the disk backing /var/lib/docker on the runner.
  2. Use multi-stage builds to shrink the exported image.
  3. Re-run; if a snapshot is corrupt, prune the build cache first.

How to prevent it

  • Reclaim disk before large builds in CI.
  • Keep exported images small with multi-stage builds.
  • Monitor free space on the runner that holds the image store.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →