yum更新/ apk更新/ apt-get更新不在代理后面工作

我在代理之后,我无法构buildDocker镜像。

我尝试FROM ubuntuFROM centosFROM alpine ,但apt-get update / yum update / apk update失败。

我的主机操作系统是Windows 10,所以我configuration了我的Docker设置来使用我们的代理。

我还补充说

 ENV http_proxy http://<PROXY> ENV https_proxy http://<PROXY> 

到我的Dockerfile但没有成功。

我也尝试将我的代理设置为http://<USER>:<PASS>@<PROXY> ,但是再次没有成功。

我能够拉动Docker镜像。 当我设置我的代理设置为没有代理 ,我无法拉图像,所以我想我的代理url是正确的。

任何想法我可以尝试什么?

编辑:

我也尝试将我们的DNS服务器(在ipconfig /all )添加到Docker设置中,但是再次没有成功。

编辑2:我只是意识到我忘记了我的Ubuntu Dockerfile中的“ http:// ”。 添加这个之后, docker build现在可以在ubuntu上正常工作 – 但只能在ubuntu上使用。 它仍然不适用于centosalpine

这里是我所有的3个Dockerfiles:

Ubuntu的:

 FROM ubuntu ENV http_proxy "http://<MY-PROXY>" ENV https_proxy "http://<MY-PROXY>" RUN apt-get update 

CentOS的:

 FROM centos ENV http_proxy "http://<MY-PROXY>" ENV https_proxy "http://<MY-PROXY>" RUN yum update 

高山:

 FROM alpine ENV http_proxy "http://<MY-PROXY>" ENV https_proxy "http://<MY-PROXY>" RUN apk update 

错误消息:

CentOS

 Step 4/4 : RUN yum update ---> Running in 3deecb71823d Loaded plugins: fastestmirror, ovl One of the configured repositories failed (Unknown), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: [...] Cannot find a valid baseurl for repo: base/7/x86_64 

高山:

 Step 4/4 : RUN apk update ---> Running in 76c8579734cf fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.6/main: could not connect to server (check repositories file) WARNING: Ignoring APKINDEX.84815163.tar.gz: No such file or directory fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz 2 errors; 11 distinct packages available ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.6/community: could not connect to server (check repositories file) WARNING: Ignoring APKINDEX.24d64ab1.tar.gz: No such file or directory The command '/bin/sh -c apk update' returned a non-zero code: 2 

您是否在RUN apt-get update指令之后设置了ENV http_proxy指令?

它们应该在使用之前设置,因为docker工人从上到下构builddocker文件的图像。

对于CentOS,我明确地必须input我的代理端口80并删除http:// -part。 所以对CentOS来说,一个工作的解决scheme看起来像这样(如果代理在端口80上运行的话):

 FROM centos ENV http_proxy=<My-PROXY>:80 ENV https_proxy=<My-PROXY>:80 RUN yum update 

高山仍然是缺less的,它看起来像需要额外的线路:

 ENV HTTP_PROXY_AUTH=basic:*:<USER>:<PASS> 

但不为我工作。 这可能是因为我的密码内有特殊字符,请参阅: https : //github.com/gliderlabs/docker-alpine/issues/305

如果我find解决scheme,我会更新这个答案。