我正面临这种情况,即基于Windows的容器失去了解析DNS的能力。
这是怎么回事
启动容器以测试dns解析
docker run -it microsoft/windowsservercore powershell
从容器内部
Test-NetConnection google.com -Port 443
与失败
PS C:> Test-NetConnection google.com -Port 443 WARNING: Name resolution of google.com failed -- Status: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server ComputerName : google.com RemoteAddress : InterfaceAlias : SourceAddress : PingSucceeded : False
但应该是这样的
PS C:\Users\asarafian> Test-NetConnection google.com -Port 443 ComputerName : google.com RemoteAddress : 216.58.204.14 RemotePort : 443 InterfaceAlias : vEthernet (External Virtual Switch) SourceAddress : 10.98.5.139 TcpTestSucceeded : True
我总是使工作站(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。
重新启动计算机不能解决问题。这是第二次发生这种情况。上一次,我必须重置整个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实例的状态,并且它们处于关闭状态。我的感觉是当超v发生某种奇怪的事情。我最怀疑的是,当hyper-v实例正在运行时,系统从休眠状态恢复时,会发生奇怪的事情。我去检查...
我做了检查,一切都还好。但是为有线网络适配器设置了hyper-v,因此在WIFI上就无法连接网络。可能是在这种情况下它们不会干扰。
更新2-20170411
根据@ chris-lawrence注释的请求,以下是来自主机以及网络上存在问题的容器内部的
ipconfig /all
。如@GSA所建议,此时容器主机上的防火墙已关闭。容器内
PS C:> ipconfig /全部
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 Update修复。但是对于有类似问题的人,我的更新仅落后了一周,而且我不认为这是问题所在。有待观察是否再次发生。
最佳答案
Docker示例之一告诉您运行此命令:
RUN Set-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord
这应该可以解决Windows容器内的DNS问题。不确定是否会帮助您,但是值得一试。
关于docker - Windows 10上托管的Windows容器会丢失其DNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43274207/