没有不值得去解决的问题,也没有不值得去学习的技术!

Error processing tar file(exit status 1): unexpected EOF 的排查分析

在 Jenkins 中构建镜像,报错:Error processing tar file(exit status 1): unexpected EOF。
1、在 Jenkins 中构建镜像,报错:Error processing tar file(exit status 1): unexpected EOF。如图1
在 Jenkins 中构建镜像,报错:Error processing tar file(exit status 1): unexpected EOF。
图1


Step 10/10 : RUN chown -R nginx:nginx /mcloud/ &&     chmod 777 /mcloud/cmp_main/data &&     chmod 777 /usr/share/sync.sh &&     chmod 777 /mcloud/cmp_main/attachment &&     chmod +x /config/init/* &&     chmod +x /etc/nginx/conf.d/* &&     chmod +x /etc/supervisord.d/* &&     rm -rf /mcloud/cmp_main/data/tpl/ &&     rm -rf /etc/nginx/conf.d/status.conf
 ---> Running in 800972ee06bc
Error processing tar file(exit status 1): unexpected EOF
Build step 'Docker Build and Publish' marked build as failure
Finished: FAILURE


2、查看 Dockerfile ,应该是 ADD 命令的行数过多了一些,进而导致空间不足。参考网址:https://stackoverflow.com/questions/42784396/docker-error-error-processing-tar-fileexit-status-1-unexpected-eof 。如图2
查看 Dockerfile ,应该是 ADD 命令的行数过多了一些,进而导致空间不足。
图2


ADD code /mcloud/cmp_main
ADD code/build/c_files/ /
ADD code/build/sync.sh /usr/share/sync.sh
ADD code/build/cacheJsSDK.sh /usr/share/cacheJsSDK.sh
ADD code/build/MP_verify_3RUFnkMVef9eh3mJ.txt /mcloud/cmp_main/
ADD code/build/MP_verify_qxIMkC3go7fNqBzb.txt /mcloud/cmp_main/

RUN sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini && \
    sed -i 's/disable_functions = exec,system/disable_functions = system/g' /usr/local/php/etc/php.ini

RUN chown -R nginx:nginx /mcloud/ && \
    chmod 777 /mcloud/cmp_main/data && \
    chmod 777 /usr/share/sync.sh && \
    chmod 777 /mcloud/cmp_main/attachment && \
    chmod +x /config/init/* && \
    chmod +x /etc/nginx/conf.d/* && \
    chmod +x /etc/supervisord.d/* && \
    rm -rf /mcloud/cmp_main/data/tpl/ && \
    rm -rf /etc/nginx/conf.d/status.conf


3、剪切 /build/sync.sh 至 /build/c_files/usr/share/sync.sh。剪切 /build/cacheJsSDK.sh 至 /build/c_files/usr/share/cacheJsSDK.sh。剪切 /build/MP_verify_3RUFnkMVef9eh3mJ.txt 至 /build/c_files/mcloud/cmp_main/MP_verify_3RUFnkMVef9eh3mJ.txt。剪切 /build/MP_verify_qxIMkC3go7fNqBzb.txt 至 /build/c_files/mcloud/cmp_main/MP_verify_qxIMkC3go7fNqBzb.txt。编辑 Dockerfile,删除了 4 行 ADD。如图3
剪切 /build/sync.sh 至 /build/c_files/usr/share/sync.sh。剪切 /build/cacheJsSDK.sh 至 /build/c_files/usr/share/cacheJsSDK.sh。剪切 /build/MP_verify_3RUFnkMVef9eh3mJ.txt 至 /build/c_files/mcloud/cmp_main/MP_verify_3RUFnkMVef9eh3mJ.txt。剪切 /build/MP_verify_qxIMkC3go7fNqBzb.txt 至 /build/c_files/mcloud/cmp_main/MP_verify_qxIMkC3go7fNqBzb.txt。编辑 Dockerfile,删除了 4 行 ADD。
图3


RUN sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini && \
    sed -i 's/disable_functions = exec,system/disable_functions = system/g' /usr/local/php/etc/php.ini

ADD code /mcloud/cmp_main
ADD code/build/c_files/ /

RUN chown -R nginx:nginx /mcloud/ && \
    chmod 777 /mcloud/cmp_main/data && \
    chmod 777 /usr/share/sync.sh && \
    chmod 777 /mcloud/cmp_main/attachment && \
    chmod +x /config/init/* && \
    chmod +x /etc/nginx/conf.d/* && \
    chmod +x /etc/supervisord.d/* && \
    rm -rf /mcloud/cmp_main/data/tpl/ && \
    rm -rf /etc/nginx/conf.d/status.conf


4、再次构建,第一次构建报错:unknown parent image ID sha256:。不过第二次构建成功。如图4
再次构建,第一次构建报错:unknown parent image ID sha256:。不过第二次构建成功。
图4
5、调整前后的镜像大小分别为:4711、3882。大小减少了:4711 – 3882 = 829。如图5
调整前后的镜像大小分别为:4711、3882。大小减少了:4711 - 3882 = 829。
图5
6、另一个可能的原因在于 Dockerfile 刚经过大幅度的修改。此种情况下,建议多构建几次。最终还是可以构建成功。

需要长期技术维护或远程问题排查?

我是拥有 15+ 年经验的 PHP / Go 后端工程师,长期关注已有系统维护、Bug 修复、性能优化、服务器排查、WordPress 网站维护和小功能迭代。

如果你的项目遇到以下情况,可以先从一次小问题排查开始合作:

  • ✅ PHP / Laravel / Yii2 老项目无人维护
  • ✅ Go / Gin 后端接口需要排查或优化
  • ✅ WordPress 网站访问慢、报错或插件冲突
  • ✅ Nginx / MySQL / Redis / Linux 服务器异常
  • ✅ CDN / Cloudflare / DNS / HTTPS 配置问题
  • ✅ 需要长期远程技术支持或兼职维护

更多介绍请查看:关于我 & 合作

微信:13980074657
邮箱:shuijingwanwq@gmail.com
Telegram:@shuijingwan
GitHub:https://github.com/shuijingwan

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理