无法通过 dockerfile 进行 apt-get 更新。无法连接到 archive.ubuntu.com:80

无法通过 dockerfile 进行 apt-get 更新。无法连接到 archive.ubuntu.com:80


目前在 Ubuntu 16.04 LTS 上,尝试使用 Docker 拉取我正在尝试安装的镜像已集成到 OSS-Fuzz 中的 AFLGo,我在第 2 步停留了很长时间。shell 脚本应该从 docker 中提取所有镜像来安装 AFLGo,但出于某种原因,无论我尝试什么,我都会不断收到此错误消息

码头工人信息:

uia65408@igl1534u:~/oss-fuzz$ docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 10
Server Version: 17.06.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 9
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.13.0-37-generic
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.44GiB
Name: igl1534u
ID: LSHK:IO3H:DHBU:OUX3:72LJ:HOYC:GIYW:QQV2:4IYC:YO7B:UXQC:FGUA
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Https Proxy: https://localhost:3128/
Username: swonlek
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

从终端,当我运行 infra/base-images/all.sh 时:

uia65408@igl1534u:~/oss-fuzz$ infra/base-images/all.sh
+ docker build --no-cache --pull -t gcr.io/oss-fuzz-base/base-image infra/base-images/base-image
Sending build context to Docker daemon   2.56kB
Step 1/9 : FROM ubuntu:16.04
16.04: Pulling from library/ubuntu
b234f539f7a1: Pull complete 
55172d420b43: Pull complete 
5ba5bbeb6b91: Pull complete 
43ae2841ad7a: Pull complete 
f6c9c6de4190: Pull complete 
Digest: sha256:b050c1822d37a4463c01ceda24d0fc4c679b0dd3c43e742730e2884d3c582e3a
Status: Downloaded newer image for ubuntu:16.04
 ---> 5e8b97a2a082
Step 2/9 : MAINTAINER [email protected]
 ---> Running in baafeed270aa
 ---> c82edcb20ed5
Removing intermediate container baafeed270aa
Step 3/9 : ENV DEBIAN_FRONTEND noninteractive
 ---> Running in b5c817be13c1
 ---> f6dc9252b91a
Removing intermediate container b5c817be13c1
Step 4/9 : RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y
 ---> Running in 7e9338006272
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Could not connect to archive.ubuntu.com:80 (91.189.88.162), connection timed out [IP: 91.189.88.162 80]
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.162 80]
Err:3 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.162 80]
Err:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Could not connect to security.ubuntu.com:80 (91.189.88.149), connection timed out [IP: 91.189.88.149 80]
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.88.162), connection timed out [IP: 91.189.88.162 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.162 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.162 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Could not connect to security.ubuntu.com:80 (91.189.88.149), connection timed out [IP: 91.189.88.149 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
 ---> 74d5fe84a2bb
Removing intermediate container 7e9338006272
Step 5/9 : ENV OUT /out
 ---> Running in 60124eb58434
 ---> 083e8bdaa793
Removing intermediate container 60124eb58434
Step 6/9 : ENV SRC /src
 ---> Running in 1a7e2f88b637
 ---> dceb04aa1080
Removing intermediate container 1a7e2f88b637
Step 7/9 : ENV WORK /work
 ---> Running in d2688371da7c
 ---> c399b9058b66
Removing intermediate container d2688371da7c
Step 8/9 : ENV PATH "$PATH:/out"
 ---> Running in 5a26db6cda09
 ---> 2dff83d2a778
Removing intermediate container 5a26db6cda09
Step 9/9 : RUN mkdir -p $OUT $SRC $WORK && chmod a+rwx $OUT $SRC $WORK
 ---> Running in cc724c7e78f3
 ---> 9c37de0bf9c6
Removing intermediate container cc724c7e78f3
Successfully built 9c37de0bf9c6
Successfully tagged gcr.io/oss-fuzz-base/base-image:latest
+ docker build --no-cache -t gcr.io/oss-fuzz-base/base-clang infra/base-images/base-clang
Sending build context to Docker daemon  6.656kB
Step 1/12 : FROM gcr.io/oss-fuzz-base/base-image
 ---> 9c37de0bf9c6
Step 2/12 : MAINTAINER [email protected]
 ---> Running in db25e12ee42d
 ---> abb0fcdd608d
Removing intermediate container db25e12ee42d
Step 3/12 : RUN apt-get -y update && apt-get install -y     libc6-dev   binutils    libgcc-5-dev
 ---> Running in 9e89aeb4e170
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Could not connect to archive.ubuntu.com:80 (91.189.88.161), connection timed out [IP: 91.189.88.161 80]
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.161 80]
Err:3 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.161 80]
Err:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Could not connect to security.ubuntu.com:80 (91.189.91.23), connection timed out [IP: 91.189.91.23 80]
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.88.161), connection timed out [IP: 91.189.88.161 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.161 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.88.161 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Could not connect to security.ubuntu.com:80 (91.189.91.23), connection timed out [IP: 91.189.91.23 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libc6-dev
E: Unable to locate package binutils
E: Unable to locate package libgcc-5-dev
The command '/bin/sh -c apt-get -y update && apt-get install -y     libc6-dev   binutils    libgcc-5-dev' returned a non-zero code: 100

基础设施/基础图像/all.sh:

docker build --no-cache --pull -t gcr.io/oss-fuzz-base/base-image $@ infra/base-images/base-image
docker build --no-cache -t gcr.io/oss-fuzz-base/base-clang $@ infra/base-images/base-clang
docker build --no-cache -t gcr.io/oss-fuzz-base/base-builder -t gcr.io/oss-fuzz/base-libfuzzer $@ infra/base-images/base-builder
docker build --no-cache -t gcr.io/oss-fuzz-base/base-runner $@ infra/base-images/base-runner
docker build --no-cache -t gcr.io/oss-fuzz-base/base-runner-debug $@ infra/base-images/base-runner-debug

基础设施/基础图像/基础图像/dockerfile:

FROM ubuntu:16.04
MAINTAINER [email protected]
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y

ENV OUT=/out
ENV SRC=/src
ENV WORK=/work
ENV PATH="$PATH:/out"

RUN mkdir -p $OUT $SRC $WORK && chmod a+rwx $OUT $SRC $WORK

基础设施/基础图像/基础clang/dockerfile:

FROM gcr.io/oss-fuzz-base/base-image
MAINTAINER [email protected]

RUN apt-get -y update && apt-get install -y \
    libc6-dev \
    binutils \
    libgcc-5-dev

COPY checkout_build_install_llvm.sh /root/
# Keep all steps in the same script to decrease the number of intermediate
# layes in docker file.
RUN /root/checkout_build_install_llvm.sh
RUN rm /root/checkout_build_install_llvm.sh

# Setup the environment.
ENV CC "clang"
ENV CXX "clang++"
ENV CCC "clang++"

# FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION is described at
# http://libfuzzer.info#fuzzer-friendly-build-mode

ENV CFLAGS "-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
ENV CXXFLAGS_EXTRA "-stdlib=libc++"
ENV CXXFLAGS "$CFLAGS $CXXFLAGS_EXTRA"

到目前为止,它只能运行到 base-clang,所以我不会用其他 dockerfiles 中不必要的代码来重复这个问题。
有连接,我可以访问http://archive.ubuntu.com/ubuntu通过浏览器。
我强烈怀疑是网络问题,因为我在公司防火墙后面工作。有很多类似的错误消息,但我找不到一个完全相同的、有答案的。或者答案适用于旧版本的 ubuntu。我已经被困了一个星期。我需要申请无代理的公司 wifi 设置吗?

答案1

我想我明白问题所在了。这与 docker 使用的代理有关,该代理无法识别(我想我之前在排除其他问题时可能将其更改为无效地址)

有两种方法可以解决此问题。在此之前,使用echo $http_proxyecho $HTTP_PROXY查找您正在使用的代理,或者如果您有另一个可用的代理,您也可以使用它。

好的,第一种方法:
如果您正在运行dockerfile,那么之前RUN apt-get update && apt-get upgrade请使用ENV设置环境
示例:

FROM ubuntu:16.04
MAINTAINER [email protected]
ENV DEBIAN_FRONTEND noninteractive
ENV http_proxy 'http://mainproxy.ucm.conti.de:8980'
ENV https_proxy 'https://mainproxy.ucm.conti.de:8980'
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y

注:根据Docker 文档,如果您想取消设置代理,则应改用 RUN,并在同一命令中取消设置,否则该值将保留在较低层。无论如何,

第二种方法:
您可以在 /etc/default/docker 中定义代理

sudo nano /etc/default/docker
//under the line "If you need Docker to use an HTTP proxy..."
#export http_proxy="http://yourproxy:port"

这对我有用!现在我遇到了另一个问题,但这个问题终于解决了!

相关内容