来自https://forums.docker.com/t/cannot-connect-to-chocolatey-org/38745的xpost

预期的行为

我正在运行Windows Server 2016数据中心(MSDN下载)64位-版本1607-版本14393.1715

我正在使用Docker For Windows并运行Windows容器。

我认为这是最简单的方法。全世界,要做到这一点:

reboot my host machine
docker run -it microsoft/windowsservercore
powershell
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));


期望将其安装在容器中。

我实际上将在dockerfile中执行此操作,但是我现在仅是一个最小的工作示例以获取帮助。

这是一个实际的docker文件,失败(可悲的是,它并不那么有创意)

FROM microsoft/windowsservercore

SHELL ["Powershell"]

ENV ChocolateyUseWindowsCompression false;
RUN iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));


实际行为

首先要做的是:我正在Virtualbox VM中运行它。我要工作的所有其他内容都可以正常工作,包括但不限于:内部网络连接和测试,运行的sql服务器,在我的docker-compose环境中运行的WCF服务,数据正确返回。我希望系统执行的所有操作均正常。这是最后一步,但愿:D。我在VirtualBox中运行此事实无关紧要,因为Hyper-V可以正常工作,并且我的所有计算机都可以正常工作。我只是觉得值得一提。

docker run -it microsoft/windowsservercore
powershell
PS C:\> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
Exception calling "DownloadString" with "1" argument(s): "The remote name could not be resolved: 'chocolatey.org'"
At line:1 char:1
+ iex ((new-object net.webclient).DownloadString('https://chocolatey.or ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

PS C:\> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : 339189e8dd56
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : attlocal.net

Ethernet adapter vEthernet (Container NIC 6412b757):

   Connection-specific DNS Suffix  . : attlocal.net
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #4
   Physical Address. . . . . . . . . : 00-15-5D-80-E9-2C
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::a51b:820e:e45d:fab6%29(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.22.202.147(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 172.22.192.1
   DNS Servers . . . . . . . . . . . : 172.22.192.1
                                       10.0.2.2
   NetBIOS over Tcpip. . . . . . . . : Disabled


从我的主机操作系统(服务器2016)中,我可以获得以下信息:

PS C:\docker> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : WIN-CDPNLUMSTOE
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : attlocal.net

Ethernet adapter vEthernet (HNS Internal NIC) 2:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 00-15-5D-80-E5-17
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::5939:52e7:aaf3:5b70%9(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.22.192.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 301995357
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-4E-0C-48-08-00-27-51-5F-6A
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter vEthernet (HNS Internal NIC) 3:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #3
   Physical Address. . . . . . . . . : 00-15-5D-B6-45-8D
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::1de4:bff7:36fb:ee92%13(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.23.128.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 570430813
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-4E-0C-48-08-00-27-51-5F-6A
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : attlocal.net
   Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Desktop Adapter
   Physical Address. . . . . . . . . : 08-00-27-51-5F-6A
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::10de:923b:b866:221d%4(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.0.2.15(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Friday, August 19, 1881 6:47:42 PM
   Lease Expires . . . . . . . . . . : Tuesday, September 26, 2017 11:15:59 PM
   Default Gateway . . . . . . . . . : 10.0.2.2
   DHCP Server . . . . . . . . . . . : 10.0.2.2
   DHCPv6 IAID . . . . . . . . . . . : 50855975
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-4E-0C-48-08-00-27-51-5F-6A
   DNS Servers . . . . . . . . . . . : 10.0.2.2
   NetBIOS over Tcpip. . . . . . . . : Enabled

Tunnel adapter isatap.{C420BD56-5715-49BF-9382-5EA99AA48563}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #5
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{70EA4F39-FE0F-4040-B718-ACAC00765808}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #6
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.attlocal.net:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : attlocal.net
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #7
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
PS C:\docker>


信息

DockerDebugInfo.ps1输出:https://gist.github.com/jcolebrand/170673e45bf8a659552f22f2071c30d6

系统信息

运行Windows Server Datacenter(MSDN下载)64位-版本1607-内部版本14393.1715

PS C:\docker> docker version
Client:
 Version:      17.06.2-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 19:57:19 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.06.2-ce
 API version:  1.30 (minimum version 1.24)
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 19:59:47 2017
 OS/Arch:      windows/amd64
 Experimental: true


如果由于任何被遗忘的原因这很重要,则确实需要激活主机操作系统。我是在一次开发环境中执行此操作的,因此,现在还不必特别担心激活VM。我无法理解这有多重要。尤其是因为其他所有东西“都可以正常工作”。

评论

似乎这里发布了类似的问题github.com/docker/for-win/issues/427尝试停止并启动docker服务。

谢谢@PrestonM,我做了很多次。并重新启动计算机。然后获取netnat |删除netnat

运行Stop-Service泊坞窗; Get-ContainerNetwork | Remove-ContainerNetwork -Force;启动服务docker提出了几个问题。找不到名称为docker的服务。没有通过Get-ContainerNetwork找到容器网络

您从哪里运行命令? Virtualbox还是Windows Server?

@PrestonM有点困惑。让我回顾一下我的设置:OSX主机-> VirtualBox-> Windows Server 2016-> Docker for Windows->容器。堆栈都在Hyper-V层上运行,并且我可以对容器执行其他所有操作,包括应用程序和本地数据库实例(microsoft / mssql-server-windows-developer)之间的内部网络通信,因此我想要的一切做的很好。这些命令以Powershell术语在容器上发出。 Server2016可以正常上网。

#1 楼

问题似乎是Windows映像将DNS配置为首先是NAT接口的默认网关,然后是主机的DNS。 DNS查找针对该第一个解析器和外部访问失败。

--dns 8.8.8.8(或您的本地解析器)添加到CLI似乎可以解决此问题。

评论


棒极了。谁可以解决积压的订单? :D

– jcolebrand
17年9月28日在19:14

@jcolebrand嗨,我也面临着同样的问题。我有企业代理配置。我们需要在哪里添加该dns配置?在daemon.json中?

–user2301
18年11月8日在13:03



您是否按照此答案中的指示尝试了命令?

– jcolebrand
18年11月8日在15:04

@jcolebrand尝试使用docker build --dns 8.8.8.8 -t choco。不工作。然后我在daemon.json中添加了“ dns”:[“ 8.8.8.8”]无效。

–user2301
18-11-9在13:46



我以为dns标志不在运行中?

– jcolebrand
18年11月9日在14:12

#2 楼

由于评论是暂时的,因此这里有一些信息供下一个人尝试解决此问题。请随意编辑此答案以提供更多详细信息,除非您是适用于Windows的Docker专业版,在这种情况下,请给出更好的答案:D

我去为我的IT小组演示问题了将我的VM上的NIC更改为桥接并添加雷电适配器之后。由于存在安全系统,所以我意识到我需要将安全软件添加到我的VM中,但是由于它没有加入域,所以这是一个问题。将其切换回wifi适配器上的NAT,然后以某种方式神奇地演示我的Windows 2016 VM中的问题,使其神奇地开始工作。

同一网络。相同的VM配置。相同的软件和主机,对我可以跟踪的任何内容均未进行任何更改。

检查了Get-ContainerNetwork或Get-WinNat却什么也没显示,我确实是在诊断工作的尽头。更改该NIC适配器然后再将其更改回显然会导致某些重置。好的时候。

所以,我没有一个可靠的答案,但是对于下一个困在鞋里的人,我有一个很好的解决方法,鉴于我对StackExchange问​​题和答案的跟踪记录,做我自己。但我希望它也能帮到您,随机的Internet询问器。


对无法解决问题的人征收XKCD税。



评论


根据此描述,我很想将帐单放在通过关闭/不关闭网络堆栈清除的DNS缓存上,因为Windows也有这种想法来缓存否定请求。如果再次发生,可能值得在Windows主机上尝试ipconfig / flushdns

–滕西拜
17年9月28日在5:38

想要添加的是,如果您的意思是托管所有内容的基本OS,则本例中的主机为OSX。如果您是说我在运行Docker容器的地方,那就是Windows。

– jcolebrand
18年1月2日在23:08

我的意思是Windows主机,我不记得基于* nix的网络堆栈缓存否定查询

–滕西拜
18年1月3日在6:22

#3 楼

在命令提示符下,运行ipconfig /all并在输出中查找带有类似IP地址的内容的DNS Servers行。那是您主机的DNS服务器。

编辑C:\ProgramData\Docker\config\daemon.json并添加带有该IP地址的dns条目。例如,如果您的DNS服务器是192.10.0.2,而8.8.8.8是Google的DNS作为备份:

{
    "dns": ["192.10.0.2", "8.8.8.8"]
}


现在重新启动Docker Desktop,可以解析远程URL由Docker在构建或运行时提供。

此解决方案来自Faithful Anere,网址为https://medium.com/@faithfulanere/solved-docker-build-could-not-resolve-archive-ubuntu -com-apt-get-fails无法安装任何东西-9ea4dfdcdcf2

#4 楼

尝试从https://chocolatey.org/install#completely-offline-install(“在代理后面安装”部分)进行安装说明:

    @powershell -NoProfile -ExecutionPolicy Bypass -Command "[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin


评论


您在这里回答另一个问题,问题是为什么容器无法解析互联网地址

–滕西拜
18年6月10日在8:21