I am behind cooperate proxy and running docker on windows 10. I have setup the proxy on docker as per the documentation here.
I am able to pull images but these proxy settings are not propagating to containers e.g. when I run alpine env, it does not show proxy conf. Below is my output
λ docker run alpine env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=14fca5bee12f
HOME=/root
Following is the expected output as per the documentation.
On building following docker file, I get connection errors from alpine container
Docker Version
Docker version 17.12.0-ce, build c97c6d6
DockerFile
FROM alpine:latest
ADD HelloWorld.class HelloWorld.class
RUN apk --update add openjdk8-jre
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "HelloWorld"]
Error
Step 3/4 : RUN apk --update add openjdk8-jre
---> Running in 1205b24d5044
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
openjdk8-jre (missing):
required by: world[openjdk8-jre]
The command '/bin/sh -c apk --update add openjdk8-jre' returned a non-zero code: 1
Passing Proxy as build-arg
I tried the following command and it worked. Is there any other way to automatically propagate the proxy settings as mentioned in documentation (see link above)
docker build --tag "docker-hello-world:latest" . --build-arg http_proxy=http://<username>:<password>@proxy_address:proxy_port/ --build-arg https_proxy=http://<username>:<password>@proxy_address:proxy_port/ --build-arg no_proxy=localhost,127.0.0.1
Operating System. If you do not run a 64-bit version of Windows Windows 10 Pro, Enterprise, or Education; 1511 November update, Build 10586 or later, you cannot run Docker for Windows. You can install Docker Toolbox if you have a 64-bit version of Windows 7 or later. Alternately, you do have the option to upgrade.
In the Docker preferences, there is an option for Proxies. If you simply click this option, you can add both an HTTP and HTTPS proxy using the Manual proxy configuration option. This setting will allow you to pull images from docker.io , however, it does not replace configuring the proxy within the container.
On the Docker client, create or edit the file ~/. docker/config. json in the home directory of the user which starts containers. Add JSON such as the following, substituting the type of proxy with httpsProxy or ftpProxy if necessary, and substituting the address and port of the proxy server.
I had the same problem. Pulling images was working but provisioning a container was not working. In this case the solution was to provide Docker with a configuration file named ~/.docker/config.json
with the following contents.
{
"proxies":
{
"default":
{
"httpProxy": "http://proxy.server....com:8080",
"httpsProxy": "https://proxy.server.....com:8080"
}
}
}
I hope this will solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With