首页 > 解决方案 > Ubuntu 16.04 映像的 Docker 构建失败 - 连接失败,返回非零代码:100

问题描述

系统详情:

以下是 Dockerfile:

FROM ubuntu:16.04

RUN apt-get update && \
apt-get install -y \
python3 python3-numpy firefox jq git-core curl python3-nose python3-pandas \
python3-pip python-wheel vim && \
pip3 install --upgrade setuptools

<Rest of the Dockerfile>

在运行命令docker build -t ubuntu-docker .时,我得到以下输出:

<< Long trace of output>>
<<....>>
Connection failed [IP: 91.189.88.152 80]
Get:348 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsnappy1v5 amd64 1.1.3-2 [16.0 kB]
Get:349 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-tables-lib amd64 3.2.2-2 [353 kB]
Get:350 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-tables all 3.2.2-2 [325 kB]
Get:351 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-tk amd64 3.5.1-1 [25.1 kB]
Get:352 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-wheel all 0.29.0-1 [48.1 kB]
Get:353 http://archive.ubuntu.com/ubuntu xenial/main amd64 rename all 0.20-4 [12.0 kB]
Get:354 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim-runtime all 2:7.4.1689-3ubuntu1.2 [5164 kB]
Get:355 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim amd64 2:7.4.1689-3ubuntu1.2 [1036 kB]
Get:356 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 xul-ext-ubufox all 3.4-0ubuntu0.16.04.2 [3302 B]
Get:357 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-scipy amd64 0.17.0-1 [8327 kB]
Fetched 236 MB in 5min 36s (700 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/n/netbase/netbase_5.3_all.deb  Connection failed [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libe/libedit/libedit2_3.1-20150325-1ubuntu2_amd64.deb  Connection failed [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gtk+3.0/libgtk-3-common_3.18.9-1ubuntu3.3_all.deb  Connection failed [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libx/libxcb/libxcb-sync1_1.11.1-1ubuntu1_amd64.deb  Connection failed [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mesa/libgl1-mesa-dri_18.0.5-0ubuntu0~16.04.1_amd64.deb  Connection failed [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mesa/libwayland-egl1-mesa_18.0.5-0ubuntu0~16.04.1_amd64.deb  Connection failed [IP: 91.189.88.149 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libx/libxrandr/libxrandr2_1.5.0-1_amd64.deb  Connection failed [IP: 91.189.88.162 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/d/dpkg/dpkg-dev_1.18.4ubuntu1.4_all.deb  Connection failed [IP: 91.189.88.149 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libg/libgphoto2/libgphoto2-port12_2.5.9-3_amd64.deb  Connection failed [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/f/fakeroot/libfakeroot_1.20.2-1ubuntu1_amd64.deb  Connection failed [IP: 91.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/p/python-decorator/python3-decorator_4.0.6-1_all.deb  Connection failed [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/python-setuptools/python3-setuptools_20.7.0-1_all.deb  Connection failed [IP: 91.189.88.152 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update && apt-get install -y python3 python3-numpy firefox jq git-core curl python3-nose python3-pandas python3-pip python-wheel vim && pip3 install --upgrade setuptools' returned a non-zero code: 100

在间隔几分钟后,我多次尝试此命令。--no-cache尝试使用选项进行构建后,我遇到了同样的错误 。

不确定这non-zero code: 100是连接失败 [IP:..] 错误的结果,还是完全有其他原因。这个解决方案也没有帮助。任何指针?

标签: macosdockerdockerfileubuntu-16.04docker-build

解决方案


只需添加这个

RUN sed -i'' 's/archive\.ubuntu\.com/us\.archive\.ubuntu\.com/' /etc/apt/sources.list

推荐阅读