本文共 2156 字,大约阅读时间需要 7 分钟。
一直运转良好的Docker自动发布突然出现了如下异常,导致无法准确构建image。
Step 3 : RUN apt-get update...Step 8 : RUN apt-get install -y openssh-client ---> Using cacheThe following NEW packages will be installed: krb5-locales libbsd0 libedit2 libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client xauth...Err:16 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openssh-client amd64 1:7.2p2-4ubuntu2.4 404 Not Found [IP: 91.189.88.162 80]...Err:16 http://security.ubuntu.com/ubuntu xenial-security/main amd64 openssh-client amd64 1:7.2p2-4ubuntu2.4 404 Not Found [IP: 91.189.88.162 80]Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openssh/openssh-client_7.2p2-4ubuntu2.4_amd64.deb 404 Not FoundE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
访问软件包发布磁盘http://security.ubuntu.com/ubuntu/pool/main/o/openssh/,发现确实没有了要获取的openssh-client_7.2p2-4ubuntu2.4_amd64.deb文件,但是存在如下文件:
访问https://pkgs.org/download/openssh-client,发现Ubuntu 16.04中可用的openssh-client如下,确实已经不用openssh-client_7.2p2-4ubuntu2.4_amd64.deb了:
访问https://launchpad.net/ubuntu/xenial/amd64/openssh-client,查看openssh-client在Ubuntu 16.04的发布历史记录如下:
原因已经一目了然了,在Ubuntu 16.04的软件包中,openssh-client已经于2018.11.06升级到1:7.2p2-4ubuntu2.6,而且过时的1:7.2p2-4ubuntu2.4已经被随后删除。但是在我们的docker build命令中,仍然试图获取已经被删除的1:7.2p2-4ubuntu2.4,所以构建失败。
那么,为什么在apt-get update之后,仍然会试图访问过时的openssh-client软件包呢?
我们看到了构建日志中紧随语句RUN apt-get install -y openssh-client的“Using cache”。原来,在Docker构建镜像的过程中,为了加快进度,在Docker命令不变的情况下,默认使用了缓存。查看docker build命令,禁用构建缓存如下:
docker build --no-cache ... 顺利解决构建镜像过程中的缓存,获取最新的openssh-client_7.2p2-4ubuntu2.6_amd64.deb。转载地址:http://jqlai.baihongyu.com/