# 处理 tar 文件时出错（退出状态 1）：tar 归档意外结束

- **ID:** `docker/tar-stream-eof-unexpected`
- **领域:** docker
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 77%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Docker 20.10.18 | active | — | — |
| Docker 24.0.2 | active | — | — |
| Registry 2.8.1 | active | — | — |

## 解决方案

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.
   ```

## 无效尝试

- **** — 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. (85% 失败率)
- **** — The error is due to data corruption, not timeout; reducing concurrency does not fix the underlying tarball integrity issue. (90% 失败率)
