docker build apt-get install 失败,错误 404

docker build apt-get install 失败,错误 404

错误

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/f/file/libmagic-mgc_5.32-2ubuntu0.1_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/f/file/libmagic1_5.32-2ubuntu0.1_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/f/file/file_5.32-2ubuntu0.1_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/libisc169_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/libdns1100_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/libisccc160_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/libisccfg160_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/libbind9-160_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/liblwres160_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/bind9-host_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/libirs160_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/b/bind9/dnsutils_9.11.3+dfsg-1ubuntu1.3_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.2_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openssh/openssh-client_7.6p1-4ubuntu0.2_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/w/wget/wget_1.19.4-1ubuntu2.1_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-utils_2.4.29-1ubuntu4.5_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

sudo apt-get 更新

      Hit:1 https://download.docker.com/linux/ubuntu bionic InRelease
  Hit:2 http://ppa.launchpad.net/jaap.karssenberg/zim/ubuntu bionic InRelease                                                        
  Hit:3 http://nginx.org/packages/mainline/ubuntu bionic InRelease                                                                     
  Hit:4 http://ppa.launchpad.net/maxmind/ppa/ubuntu bionic InRelease                                        
  Hit:5 http://us.archive.ubuntu.com/ubuntu bionic InRelease               
  Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
  Get:7 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B]
  Get:8 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [20.8 kB]
  Get:9 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] 
  Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [12.2 kB]
  Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [45.2 kB]
  Get:12 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
  Get:13 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,460 B]
  Get:14 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [278 kB]
  Get:15 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.7 kB]
  Get:16 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [123 kB]                                                                                                    
  Get:17 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [209 kB]                                                                                                          
  Get:18 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [192 kB]                                                                                                                  
  Get:19 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [359 kB]                                                                                                                        
  Get:20 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]                                                                                                            
  Get:21 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,352 B]                                                      
  Fetched 1,570 kB in 10s (160 kB/s)                                                                                                                               
  Reading package lists... Done

我的笔记本电脑配置

DNS: 8.8.8.8
Kernel: Linux ****** 4.15.0-44-generic #47-Ubuntu SMP Mon Jan 14 11:26:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Docker version: 18.09.5, build e8ff056

os-release: 
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic 

sources-list:
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
# deb http://archive.canonical.com/ubuntu bionic partner
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

# deb-src http://au.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
# deb-src http://au.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src http://au.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
# deb-src http://archive.canonical.com/ubuntu bionic partner
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

了解如何解决这个问题。

答案1

清理你的docker缓存。

在你的 Dockerfile 中你可能会有类似这样的内容:

RUN apt-get update

当您运行docker build ...查看日志时,您可能会找到using cache此命令。

只需清理您的缓存,我刚刚运行了docker rm <image id> -f几次(虽然选择合适的图像可能很棘手)并且解决了这个问题。

相关内容