我正面临这种情况,我的基于 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 的名称解析失败 -- 状态:这通常是主机名解析期间的临时错误,意味着本地服务器没有收到来自权威服务器的响应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。
- 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 更新解决了这个问题。但是对于遇到类似问题的人来说,我在更新方面只落后了一周,我不认为这是问题所在。是否会再次发生有待观察。