【问题标题】:error in docker build - Err:1 http://deb.debian.org/debian stretch/main amd64 unzip amd64 6.0-21+deb9u1 404 Not Founddocker build 中的错误 - Err:1 http://deb.debian.org/debian stretch/main amd64 unzip amd64 6.0-21+deb9u1 404 Not Found
【发布时间】:2020-05-09 17:56:34
【问题描述】:

我正在我的 MacBook Pro 上进行 docker 构建,但它总是失败并出现以下错误:

Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
  zip
The following NEW packages will be installed:
  unzip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 170 kB of archives.
After this operation, 547 kB of additional disk space will be used.
Err:1 http://deb.debian.org/debian stretch/main amd64 unzip amd64 6.0-21+deb9u1
  404  Not Found
E: Failed to fetch http://deb.debian.org/debian/pool/main/u/unzip/unzip_6.0-21+deb9u1_amd64.deb  404  Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get install unzip' returned a non-zero code: 100

码头工人版本: Docker 版本 19.03.8,构建 afacb8b

MacOS:莫哈韦 10.14.6

Dockerfile sn-p:

FROM debian:latest
RUN apt-get update
RUN apt-get install -y ca-certificates
RUN apt-get install unzip

在我们使用 docker-ce=17.09.0~ce-0~ubuntu 的 travis CI 中构建工作正常

关于如何进一步调试它有什么建议吗?最初我们认为这可能是 debian 方面的临时问题,但问题一直存在,很可能是我的环境问题。

【问题讨论】:

  • 将三个apt-get 命令组合成一个RUN 命令有帮助吗? docker build 输出是否在您引用的内容上方包含“使用缓存”行?
  • Sending build context to Docker daemon 91.25MB Step 1/10 : FROM debian:latest ---> 8d31923452f8 Step 2/10 : RUN apt-get update ---> 使用缓存 ---> 3140f7361780

标签: docker debian apt-get


【解决方案1】:

将您显示的三个RUN 行组合成一个命令:

FROM debian:latest
RUN apt-get update \
 && apt-get install -y \
      ca-certificates \
      unzip

导致 404 错误的原因有两个。一方面,Docker 会缓存单个 Dockerfile 步骤:它看到,从 debian:latest 开始,已经是 RUN apt-get update,所以它使用昨天的那个命令的版本。另一方面,Debian 非常频繁地更新他们的存储库,更新非常小(请参阅该版本号的+deb9u1 部分),当他们这样做时,他们会从其存储库中删除以前的版本。这种组合意味着您可以在序列中使用apt-get update 索引的缓存版本,但它提到的包版本不再存在。

像这样将这些行组合在一起意味着 Docker 将始终同时运行 apt-get updateapt-get install;如果您将包添加到列表中,它将在尝试下载内容之前重新运行update 步骤。这样可以避免这个问题,但代价是包列表更改时会增加一点下载时间。

【讨论】:

  • 感谢大卫。将三个 RUN 行合并为一个命令的变化有效。感谢您分享的详细解释。
猜你喜欢
  • 2019-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多