Update yum update / apk update / apt-get does not work for proxy server

I am behind a proxy server and I cannot create a Docker image.

I tried with FROM ubuntu , FROM centos and FROM alpine , but apt-get update / yum update / apk update failed.

My OS host is Windows 10, so I configured Docker options to use our proxy server.

And I also added

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

to my Docker file but will fail.

I also tried setting my proxy to http://<USER>:<PASS>@<PROXY> , but again failed.

I can pull out Docker images. When I set my proxy settings without a proxy, I can’t retrieve the images, so I assume that my proxy URL is correct.

Any ideas what else I can try?

Edit:

I also tried adding our DNS server (which is specified in ipconfig /all ) to the Docker settings, but again failed.

Edit2: I just realized that I forgot "http: //" in my Ubuntu Dockerfile. By adding this, docker build now works great for ubuntu, but only for ubuntu. It still does not work for centos and alpine .

Here are all my 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 

Alpine:

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

Error messages:

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 

Alpine:

 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 
0
docker proxy dockerfile docker-for-windows
Oct 25 '17 at 11:12
source share
2 answers

Did you install the ENV http_proxy instructions after the RUN apt-get update command?

They must be installed before they are used, as docker creates an image from the docker file from top to bottom.

0
Oct 25 '17 at 11:15
source share

For CentOS, I obviously had to enter my proxy port 80 and delete http:// -part. Thus, for CentOS, the working solution looks like this (if the proxy runs on port 80):

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

Alpine is still missing, it looks like an extra line is required:

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

but not working for me. This may be due to special characters inside my password, see: https://github.com/gliderlabs/docker-alpine/issues/305

I will update this answer if I find a solution.

0
Oct 26 '17 at 8:27
source share



All Articles