我在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版本:Docker版本19.03.8,构建afacb8b
MacOS:Mojave 10.14.6
Dockerfile片段:
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方面的临时问题,但问题仍然存在,因此很可能与我的环境有关。
将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
索引的缓存版本,但是它所提到的软件包版本不再存在。
这些线结合在一起像这样的手段泊坞窗将始终同时运行apt-get update
并apt-get install
一起; 如果您将软件包添加到列表中,它将update
在尝试下载内容之前重新运行该步骤。这样可以避免此问题,但打包列表更改时会花费一些额外的下载时间。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句