首页 > 解决方案 > 如何在 Docker 内运行的 Windows 上配置代理服务器?

问题描述

我在 Windows Server 2019 上运行 Docker,在 Docker 中我运行 servercore:ltsc2019。但我未能正确配置代理服务器。

主机和 docker 守护进程配置为使用代理服务器。我可以提取图像并运行它,但是,正在运行的容器似乎没有使用代理服务器。

我可以ping内部和外部主机。我也可以从内部服务器下载:(New-Object System.Net.WebClient).DownloadString('http://a.server.lokal'). 但是如果我尝试外部地址,我会得到一个例外:

Exception calling "DownloadString" with "1" argument(s): "Unable to connect to the remote server"

我已经尝试使用以下方法设置代理服务器:

netsh winhttp set proxy "http://<ip>:<port>"

并且:

$rkey="HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set-ItemProperty -path $rkey ProxyEnable -value 1
Set-ItemProperty -path $rkey ProxyServer -value "http://<ip>:<port>"

但这也无济于事。

那么如何配置代理服务器呢?

标签: windowsdockerhttp-proxy

解决方案


推荐阅读