Geerten Verweij
Geerten Verweij

Reputation: 33

Docker on Windows with a proxy

Hi im using Docker on windows 10 with a proxy. Docker itself works fine with the proxy IP set correctly in the docker settings. I can download images through docker.

The problem is that any container I want to run or build also needs these HTTP_PROXY and HHTPS_PROXY variables. I can do this by adding it to build arguments, run arguments or the docker file. However none of these solutions are perfect because they add machine specific variable values to either the docker files and/or the docker-compose files.

I have checked the MobyLinuxVM's values for these HTTP_PROXY and HHTPS_PROXY variables by hacking into it with this trick: How to connect to docker VM (MobyLinux) from windows shell?

Eventhough these variables were displayed correctly any image that I run or dockerfile I build still needs to get these variables.

Is there a way that any container automatically gets these proxy environment variables from the docker deamon who already has them set? I know Linux has this feature by nature, but it seems to be missing for Windows.

Upvotes: 0

Views: 6208

Answers (2)

Amanda Debler
Amanda Debler

Reputation: 178

This does not provide a way to set those values or to get them in a container's context, but has stopped me from having to change my proxy settings every time I change IP addresses and keeps me from having to pass them to containers at runtime (builds are still a different story).

This works for me behind an NTLM-authenticating web proxy, even from home on VPN:

1) Get the IP address of the DummyDesperatePoitras virtual switch Docker for Windows creates (starts with 169.254., which is usually a non-routable IP)

2) Install CNTLM (not perfect, as it's not been updated in 5 years) and set it to listen on that "dummy" IP address

3) Use that "dummy" IP address as the proxy in Docker for Windows settings

4) Add your internal corporate DNS server's IP and the domain name to the daemon.json in Docker for Windows settings

Again, this works for running containers - I only have to deal with the proxy server when I run docker build, passing it along in the build-args. I've not found a way around that yet.

Detailed walkthrough: https://mandie.net/2017/12/10/docker-for-windows-behind-a-corporate-web-proxy-tips-and-tricks/

Upvotes: 1

yamenk
yamenk

Reputation: 51768

My advice is to use a tool to transparently route all your traffic to the proxy, without having to set any proxy configuration locally.

For windows there is proxifier. It will transparently route all the traffic from your host to the proxy.

Upvotes: 0

Related Questions