docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.85k stars 287 forks source link

Set container level proxy using netsh or even OS registry edit #3475

Open ardalon opened 5 years ago

ardalon commented 5 years ago

Expected behavior

Internet access available without needing to explicitly set -Proxy type switches on each and every CLI command. OR using a command such as netsh winhttp set proxy

Proxy configuration should be a machine/container level setting much as it is on the OS itself.

Actual behavior

No internet access available without using a -Proxy flag (on commands that support it)

Information / Workaround

Rather than an environment variable that I reference in each CLI command (and one that I will have to manually remove from each place in my code should I no longer need to use a proxy resulting in brittle code) there should be a mechanism, such as via netsh that will allow

This clever but hacky solution works on:

Windows Server 2016 [Version 1607 (OS Build 14393.2724) using the image: microsoft/dotnet-framework:4.7.2-sdk-20180615-windowsservercore-ltsc2016

Docker versions:

Client: Version: 17.06.2-ee-11

Server: Engine: Version: 17.06.2-ee-11 Experimental: false

however it does NOT work on:

Windows Server 2019 [Version 1809 (OS Build 17763.253) using the image: microsoft/dotnet-framework:4.7.2-sdk-20190108-windowsservercore-ltsc2019

Docker versions:

Client: Version: 18.03.1-ee-6

Server: Engine: Version: 18.03.1-ee-6 Experimental: false

Steps to reproduce the behavior

  1. Export Registry key: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings] to a file proxy.reg

docker run -e "HTTP_PROXY=http://ProxyIP:ProxyPort" --rm -i -t -v C:\PathToHostFiles:C:\solution microsoft/dotnet-framework:4.7.2-sdk-20190108-windowsservercore-ltsc2019 "cd \solution ; regedit.exe -S proxy.reg ; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord ; wget -outfile asdf.txt -usebasicparsing http://google.com ; cat asdf.txt "

docker-robott commented 5 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

startere commented 5 years ago

/remove-lifecycle stale

startere commented 5 years ago

Have you found a different solution than the one with the .reg file posted in your link?

ardalon commented 5 years ago

Unfortunately no. We are using proxy switches and environment variables as reqd per command and using powershell script to automate this a bit. We are using 2019 containers now so we can't use the registry hack -- which I don't recommend even on 2016 containers.

docker-robott commented 5 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

ThomasPiskol commented 5 years ago

/lifecycle frozen

ThomasPiskol commented 5 years ago

/remove-lifecycle stale