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.
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 deviceCommon 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.
docker system prune -af --volumes
docker builder prune -afGrow the build disk or reduce image size
- Increase the disk backing
/var/lib/dockeron the runner. - Use multi-stage builds to shrink the exported image.
- 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.