docker build_error ai_generated true

Error processing tar file(exit status 1): unexpected end of tar archive

ID: docker/tar-stream-eof-unexpected

Also available as: JSON · Markdown · 中文
77%Fix Rate
83%Confidence
1Evidence
2023-05-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Docker 20.10.18 active
Docker 24.0.2 active
Registry 2.8.1 active

Root Cause

A layer tarball in the Docker image is corrupted or truncated, often due to network interruption during pull, incomplete upload to registry, or disk I/O errors.

generic

中文

Docker 镜像中的层 tarball 损坏或截断,通常是由于拉取时的网络中断、上传到注册表不完整或磁盘 I/O 错误导致。

Official Documentation

https://docs.docker.com/engine/reference/commandline/save/

Workarounds

  1. 80% success Delete the specific corrupted image layer: `docker rmi <image>:<tag>` and then re-pull the image from the registry with `docker pull <image>:<tag>`. If the error persists, the registry image itself is corrupted; push a fresh build.
    Delete the specific corrupted image layer: `docker rmi <image>:<tag>` and then re-pull the image from the registry with `docker pull <image>:<tag>`. If the error persists, the registry image itself is corrupted; push a fresh build.
  2. 70% success If the image is local, export and re-import: `docker save myimage:latest -o myimage.tar && docker rmi myimage:latest && docker load -i myimage.tar`. This can fix minor tar header corruption.
    If the image is local, export and re-import: `docker save myimage:latest -o myimage.tar && docker rmi myimage:latest && docker load -i myimage.tar`. This can fix minor tar header corruption.

中文步骤

  1. Delete the specific corrupted image layer: `docker rmi <image>:<tag>` and then re-pull the image from the registry with `docker pull <image>:<tag>`. If the error persists, the registry image itself is corrupted; push a fresh build.
  2. If the image is local, export and re-import: `docker save myimage:latest -o myimage.tar && docker rmi myimage:latest && docker load -i myimage.tar`. This can fix minor tar header corruption.

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Pruning removes all images and containers but does not repair the corrupted layer; the error will reappear when pulling the same image again from the same registry.

  2. 90% fail

    The error is due to data corruption, not timeout; reducing concurrency does not fix the underlying tarball integrity issue.