docker - apt-get update 失败,但退出状态仍然成功,这破坏了我的 docker 缓存

标签 docker ubuntu debian apt-get

这里是 docker build log 的重要部分

#6 [stage-1  2/20] RUN apt-get -y update && apt-get -y upgrade
#6 sha256:6a65c591472319f4cf0c6954f890ee1d5e465b9b12670d78dd15e738cf4bd37d
#6 31.57 Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
#6 31.57   Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
#6 31.57 Err:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
#6 31.57   Unable to connect to archive.ubuntu.com:http:
#6 31.57 Err:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
#6 31.57   Unable to connect to archive.ubuntu.com:http:
#6 32.00 Err:4 http://security.ubuntu.com/ubuntu focal-security InRelease
#6 32.00   Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
#6 32.02 Reading package lists...
#6 32.04 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
#6 32.04 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Unable to connect to archive.ubuntu.com:http:
#6 32.04 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Unable to connect to archive.ubuntu.com:http:
#6 32.04 W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
#6 32.04 W: Some index files failed to download. They have been ignored, or old ones used instead.
#6 32.06 Reading package lists...
#6 32.08 Building dependency tree...
#6 32.08 Reading state information...
#6 32.08 Calculating upgrade...
#6 32.08 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
#6 DONE 32.3s
如您所见,有一些错误,但出于某种原因,docker 认为这两个命令都以成功结束:#6 DONE 32.3s .
这破坏了我的 Docker 缓存并在构建机器上产生了问题。
问题
现在的问题不是如何修复这一步,这由 other SO questions 提供。 (other)。
我怎样才能防止这个问题并强制 apt-get报告错误(无零退出代码)。在我的情况下,问题是临时网络问题和这个损坏的 docker 缓存。我已清除缓存以解决此问题,但如何防止此问题在 future 重复出现?

最佳答案

这些不被视为错误,而是警告,正如您在 W 中看到的那样。在线前。
您可以制作apt-get update添加以下 -o APT::Update::Error-Mode=any 以失败告终

关于docker - apt-get update 失败,但退出状态仍然成功,这破坏了我的 docker 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71220914/

相关文章:

docker - 水平扩展聊天日志 worker

docker - 为特定上下文构建 Heroku docker 镜像

带参数的 Docker ENTRYPOINT shell 形式

node.js - systemd日志每日汇总-linux

docker - 按镜像名称停止 Docker 容器 - Ubuntu

linux - 获取静态链接Qt5的XCB插件的加载库或链接错误

repository - 创建本地 debian 存储库

apache - 德类、 Apache 。日志文件占用了所有磁盘空间

docker - 为什么redis不能访问docker-compose中的磁盘?

ubuntu - aspell api 文档