【问题标题】:Windows Containers hosted on Windows 10 lose their DNS托管在 Windows 10 上的 Windows 容器丢失其 DNS
【发布时间】:2017-04-07 09:11:33
【问题描述】:

我正面临这种情况,我的基于 Windows 的容器失去了解析 DNS 的能力。

这就是发生的事情

启动一个容器来测试 dns 解析 docker run -it microsoft/windowsservercore powershell

从容器内部

Test-NetConnection google.com -Port 443

失败

PS C:> Test-NetConnection google.com -Port 443 警告:google.com 的名称解析失败 -- 状态:这通常是主机名解析期间的临时错误,意味着本地服务器没有收到来自权威服务器的响应 计算机名称:google.com 远程地址: 接口别名: 源地址: PingSucceeded : 假

但应该是这样的

PS C:\Users\asarafian> Test-NetConnection google.com -Port 443 计算机名称:google.com 远程地址:216.58.204.14 远程端口:443 InterfaceAlias:vEthernet(外部虚拟交换机) 源地址:10.98.5.139 TcpTestSucceeded : 真

我总是使工作站 (Windows 10) 休眠,并在其上运行 Hyper-V 实例和 Docker。工作站是 Windows 10,据我所知,当问题发生时,它使用 Windows 10 主机的 IP 作为 DNS。

从容器内

PS C:\> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : c7c016e13be8
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Ethernet 2:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Hyper-V Network Adapter #2
   Physical Address. . . . . . . . . : Deducted
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::bc61:e687:4676:353a%5(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.19.143.229(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 172.19.128.1
   DHCPv6 IAID . . . . . . . . . . . : Deducted
   DHCPv6 Client DUID. . . . . . . . : Deducted
   DNS Servers . . . . . . . . . . . : 172.19.128.1
   NetBIOS over Tcpip. . . . . . . . : Disabled

172.19.128.1 是我的 Windows 10 主机 IP。

同时,当Windows 10主机容器卡住时,其他一切正常解析DNS。

  • Windows 10 上的任何进程。
  • Windows 10 上的 Hyper-V 实例。
  • 容器托管在 Windows 10 上的 Hyper-V 实例上。

重启机器并不能解决问题。这是第二次出现这种情况。以前我不得不重置整个 docker 安装来解决这个问题。我想避免这种情况并了解问题所在以及如何解决。

Docker 版本是

C:\Users\asarafian>docker version
Client:
 Version:      17.03.1-ce-rc1
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   3476dbf
 Built:        Wed Mar 15 20:33:22 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.03.1-ce-rc1
 API version:  1.27 (minimum version 1.24)
 Go version:   go1.7.5
 Git commit:   3476dbf
 Built:        Wed Mar 15 20:33:22 2017
 OS/Arch:      windows/amd64
 Experimental: false

更新 1 - 20170408

根据@chris-lawrence 评论的要求,以下是来自主机和容器内部的ipconfig /all。有趣的方面是 dns 解析在容器内部起作用。

容器内

PS C:\> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : 476d22f638ea
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : home

Ethernet adapter Ethernet 2:

   Connection-specific DNS Suffix  . : home
   Description . . . . . . . . . . . : Microsoft Hyper-V Network Adapter #2
   Physical Address. . . . . . . . . : 00-15-5D-53-0A-2A
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::ad59:83cc:6e64:944a%5(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.19.132.10(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 172.19.128.1
   DHCPv6 IAID . . . . . . . . . . . : 83891549
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-7A-A9-D0-00-15-5D-53-0A-2A
   DNS Servers . . . . . . . . . . . : 172.19.128.1
                                       192.168.0.1
   NetBIOS over Tcpip. . . . . . . . : Disabled

在容器主机上

Windows IP Configuration

   Host Name . . . . . . . . . . . . : MECDEVASAR03
   Primary Dns Suffix  . . . . . . . : global.sdl.corp
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : global.sdl.corp
                                       sdl.corp
                                       maidenhead.sdl.corp
                                       sheffield.sdl.corp
                                       development.sheffield.sdl.corp
                                       irv.languageweaver.com
                                       languageweaver.com
                                       montreal.sdl.corp
                                       singapore.sdl.corp
                                       bray.sdl.corp
                                       seoul.sdl.corp
                                       idiominc.priv
                                       sdlproducts.com
                                       lan.lon.sdlproducts.com
                                       freetranslation.corp
                                       xyenterprise.com
                                       alterian.com
                                       ams.dev
                                       sdlntt.corp

Ethernet adapter vEthernet (HNS Internal NIC):

   Connection-specific DNS Suffix  . : 
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   Physical Address. . . . . . . . . : 00-15-5D-53-04-CB
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::f5c8:e8c7:1ad0:d845%26(Preferred) 
   IPv4 Address. . . . . . . . . . . : 172.19.128.1(Preferred) 
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 
   DHCPv6 IAID . . . . . . . . . . . : 436213085
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1F-AD-0A-F4-18-DB-F2-15-03-E7
   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 (External Virtual Switch):

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : global.sdl.corp
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 18-DB-F2-15-03-E7
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : 
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
   Physical Address. . . . . . . . . : B8-08-CF-44-25-D9
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . : home
   Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8260
   Physical Address. . . . . . . . . : B8-08-CF-44-25-D8
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::6d3a:ef28:a057:6108%18(Preferred) 
   IPv4 Address. . . . . . . . . . . : 192.168.0.103(Preferred) 
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Saturday, 8 April 2017 16:17:24
   Lease Expires . . . . . . . . . . : Saturday, 15 April 2017 16:24:09
   Default Gateway . . . . . . . . . : 192.168.0.1
   DHCP Server . . . . . . . . . . . : 192.168.0.1
   DHCPv6 IAID . . . . . . . . . . . : 45615311
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1F-AD-0A-F4-18-DB-F2-15-03-E7
   DNS Servers . . . . . . . . . . . : 192.168.0.1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : 
   Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
   Physical Address. . . . . . . . . : B8-08-CF-44-25-DC
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.global.sdl.corp:

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

Tunnel adapter isatap.{5C890AAE-6E73-44BB-BB1E-DE8EB4794BF8}:

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

Tunnel adapter isatap.home:

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

出于好奇,我检查了 hyper-v 实例的状态,它们已关闭。我的感觉是,当 hyper-v(s).我最怀疑的是,当系统在 hyper-v 实例运行时从休眠状态恢复时会发生一些奇怪的事情。我去查一下……

我做了检查,一切都还好。但是 hyper-v(s) 是为有线网络适配器设置的,因此在 WIFI 上则没有网络。可能是在这种情况下他们不干涉。

更新 2 - 20170411

根据@chris-lawrence 评论的要求,以下是来自主机和容器内部的ipconfig /all在有问题的网络上。正如@GSA 所建议的那样,此时容器主机上的防火墙已关闭。

容器内

PS C:> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : d4e9a6d59f93
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Ethernet 2:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Hyper-V Network Adapter #2
   Physical Address. . . . . . . . . : 00-15-5D-53-00-71
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::a08a:68b:1c3d:fe6e%5(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.19.135.4(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 172.19.128.1
   DHCPv6 IAID . . . . . . . . . . . : 83891549
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-7E-30-BE-00-15-5D-53-00-71
   DNS Servers . . . . . . . . . . . : 172.19.128.1
   NetBIOS over Tcpip. . . . . . . . : Disabled

我注意到只有 一个 dns 条目 172.19.128.1 是内部 docker。

在容器主机上

Windows IP Configuration

   Host Name . . . . . . . . . . . . : MECDEVASAR03
   Primary Dns Suffix  . . . . . . . : global.sdl.corp
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : global.sdl.corp
                                       sdl.corp
                                       maidenhead.sdl.corp
                                       sheffield.sdl.corp
                                       development.sheffield.sdl.corp
                                       irv.languageweaver.com
                                       languageweaver.com
                                       montreal.sdl.corp
                                       singapore.sdl.corp
                                       bray.sdl.corp
                                       seoul.sdl.corp
                                       idiominc.priv
                                       sdlproducts.com
                                       lan.lon.sdlproducts.com
                                       freetranslation.corp
                                       xyenterprise.com
                                       alterian.com
                                       ams.dev
                                       sdlntt.corp

Ethernet adapter vEthernet (HNS Internal NIC):

   Connection-specific DNS Suffix  . : 
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   Physical Address. . . . . . . . . : 00-15-5D-53-04-CB
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::f5c8:e8c7:1ad0:d845%26(Preferred) 
   IPv4 Address. . . . . . . . . . . : 172.19.128.1(Preferred) 
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 
   DHCPv6 IAID . . . . . . . . . . . : 436213085
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1F-AD-0A-F4-18-DB-F2-15-03-E7
   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 (External Virtual Switch):

   Connection-specific DNS Suffix  . : global.sdl.corp
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 18-DB-F2-15-03-E7
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::5814:8934:3247:a4bf%10(Preferred) 
   IPv4 Address. . . . . . . . . . . : 10.98.5.139(Preferred) 
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Lease Obtained. . . . . . . . . . : Tuesday, 11 April 2017 08:08:21
   Lease Expires . . . . . . . . . . : Wednesday, 19 April 2017 08:08:20
   Default Gateway . . . . . . . . . : 10.98.1.1
   DHCP Server . . . . . . . . . . . : 10.98.3.7
   DHCPv6 IAID . . . . . . . . . . . : 504945650
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1F-AD-0A-F4-18-DB-F2-15-03-E7
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
                                       10.98.3.7
                                       10.98.3.5
                                       10.20.3.169
   Primary WINS Server . . . . . . . : 10.100.3.100
   NetBIOS over Tcpip. . . . . . . . : Enabled

Wireless LAN adapter Local Area Connection* 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : 
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
   Physical Address. . . . . . . . . : B8-08-CF-44-25-D9
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : 
   Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
   Physical Address. . . . . . . . . : B8-08-CF-44-25-DC
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter vEthernet (Wireless External Virtual Switch):

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : global.sdl.corp
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #3
   Physical Address. . . . . . . . . : B8-08-CF-44-25-D8
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.global.sdl.corp:

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

Tunnel adapter isatap.{5C890AAE-6E73-44BB-BB1E-DE8EB4794BF8}:

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

更新 3 - 问题已修复

我刚刚升级到 Windows 10 创建者更新,突然问题就停止了。目前,我认为通过 Windows 更新解决了这个问题。但是对于遇到类似问题的人来说,我在更新上只落后了一周,我不认为这是问题所在。是否会再次发生,待观察。

【问题讨论】:

  • 检查你的防火墙是否阻止它
  • 哪个防火墙?在容器内部还是在主机内部(Windows 10)?如果它在主机上阻止它,那么为什么其他一切都在工作呢?另外,你会如何解释突然的变化? docker 是否在系统上做某事,例如Windows 更新可以覆盖?
  • 主机防火墙。如果它打开,很多东西可能会运行不可靠。
  • 你能把主机的 ipconfig /all 的输出贴出来吗?
  • 应该在同一个网络吗?如果是,那么我们需要等到星期二。同时,我将尝试将笔记本电脑连接到我的家庭无线网络时会发生什么。

标签: docker docker-for-windows


【解决方案1】:

其中一个 Docker 示例告诉您运行这个:

  RUN Set-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord

这应该解决 Windows 容器内的 DNS 问题。不确定它是否会对您有所帮助,但值得一试。

【讨论】:

  • 谢谢。我目前没有使用容器,并且问题在停止之前已经停止了一段时间,因此我无法验证。但这是一个有趣的建议,请记住以供将来参考和其他可能遇到相同问题的人参考。
猜你喜欢
  • 2013-05-15
  • 2019-02-22
  • 1970-01-01
  • 1970-01-01
  • 2020-07-26
  • 1970-01-01
  • 2015-08-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多