gpt4 book ai didi

docker-swarm - 部署服务时如何修复 Docker 错误 "hnsCall failed in Win32: An adapter was not found"?

转载 作者:行者123 更新时间:2023-12-04 04:39:45 28 4
gpt4 key购买 nike

我正在尝试从我的主机运行一个四节点集群,我的机器是管理器,三个 Hyper-V 虚拟机作为工作节点。
我正在尝试在所有节点上将静态网页作为服务运行,但不断收到 hnsCall failed in Win32: An adapter was not found我的主机错误,No such image从虚拟机(试图从私有(private)注册表中提取服务镜像)。
部署堆栈或使用 service create 时会发生这种情况.
但是,我可以通过容器实例运行静态页面,它工作正常。

我关注了this guide设置和创建我的虚拟机,我怀疑这是我的问题出现的地方。
我通过 HyperV 虚拟交换机管理器创建的虚拟交换机,名为 thevswitch , 是外部的并且设置在正确的适配器上。我在 thevswitch 下使用主机的 IPv4 初始化了一个 swarm对于--advertise-addr标志,并在使用驱动程序时成功地将虚拟机作为工作节点加入到此 IP。无论如何,Docker 似乎都看不到我创建的虚拟交换机。

PS C:\Docker\swarm-test> docker version
Client: Docker Engine - Community
Version: 18.09.2
API version: 1.39
Go version: go1.10.8
Git commit: 6247962
Built: Sun Feb 10 04:12:31 2019
OS/Arch: windows/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.24)
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 04:28:48 2019
OS/Arch: windows/amd64
Experimental: true
PS C:\Docker\swarm-test> docker network ls
NETWORK ID NAME DRIVER SCOPE
3f4030aafa56 Default Switch ics local
m1c2nzylf14x ingress overlay swarm
168954d1275d nat nat local
be3f092c32cb none null local
PS C:\Docker\swarm-test> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
4xiljuldm32avsxwo8o513uv5 * ATLL000597 Ready Active Leader 18.09.2
w2ftfwt4oz00keswt6ztmq9ec vm1 Ready Active 18.09.6
82vpc65ezml87sxhhx9mlvszk vm2 Ready Active 18.09.6
lej0a3gabyi3qfta1f4le1f3s vm3 Ready Active 18.09.6
PS C:\Docker\swarm-test> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
vm1 - hyperv Running tcp://10.195.12.68:2376 v18.09.6
vm2 - hyperv Running tcp://10.195.12.69:2376 v18.09.6
vm3 - hyperv Running tcp://10.195.12.75:2376 v18.09.6

主机ipconfig:
PS C:\Docker\swarm-test> ipconfig

Windows IP Configuration


Ethernet adapter Ethernet 3:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Ethernet adapter vEthernet (thevswitch):

Connection-specific DNS Suffix . : Int.CSDental.com
Link-local IPv6 Address . . . . . : fe80::e90f:a37:5f33:87de%29
IPv4 Address. . . . . . . . . . . : 10.195.12.87
Subnet Mask . . . . . . . . . . . : 255.255.252.0
Default Gateway . . . . . . . . . : 10.195.12.1

Wireless LAN adapter Wi-Fi:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Wireless LAN adapter Local Area Connection* 9:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Wireless LAN adapter Local Area Connection* 10:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Ethernet adapter Ethernet 4:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Ethernet adapter Bluetooth Network Connection:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Ethernet adapter vEthernet (Default Switch) 2:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::5de7:19c9:a701:b06a%65
IPv4 Address. . . . . . . . . . . : 192.168.55.33
Subnet Mask . . . . . . . . . . . : 255.255.255.240
Default Gateway . . . . . . . . . :

Ethernet adapter vEthernet (nat) 2:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::f173:8:f6e1:123c%73
IPv4 Address. . . . . . . . . . . : 172.26.192.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :


主机(经理):
PS C:\Docker\swarm-test> docker inspect ATLL000597
[
{
"ID": "4xiljuldm32avsxwo8o513uv5",
"Version": {
"Index": 23501
},
"CreatedAt": "2019-05-29T16:41:17.1544224Z",
"UpdatedAt": "2019-05-29T17:35:40.2375377Z",
"Spec": {
"Labels": {},
"Role": "manager",
"Availability": "active"
},
"Description": {
"Hostname": "ATLL000597",
"Platform": {
"Architecture": "x86_64",
"OS": "windows"
},
"Resources": {
"NanoCPUs": 8000000000,
"MemoryBytes": 16971313152
},
"Engine": {
"EngineVersion": "18.09.2",
"Plugins": [
{
"Type": "Log",
"Name": "awslogs"
},
{
"Type": "Log",
"Name": "etwlogs"
},
{
"Type": "Log",
"Name": "fluentd"
},
{
"Type": "Log",
"Name": "gelf"
},
{
"Type": "Log",
"Name": "json-file"
},
{
"Type": "Log",
"Name": "local"
},
{
"Type": "Log",
"Name": "logentries"
},
{
"Type": "Log",
"Name": "splunk"
},
{
"Type": "Log",
"Name": "syslog"
},
{
"Type": "Network",
"Name": "ics"
},
{
"Type": "Network",
"Name": "l2bridge"
},
{
"Type": "Network",
"Name": "l2tunnel"
},
{
"Type": "Network",
"Name": "nat"
},
{
"Type": "Network",
"Name": "null"
},
{
"Type": "Network",
"Name": "overlay"
},
{
"Type": "Network",
"Name": "transparent"
},
{
"Type": "Volume",
"Name": "local"
}
]
},
"TLSInfo": {
"TrustRoot": "-----BEGIN CERTIFICATE-----\nMIIBazCCARCgAwIBAgIUew6Ov5cRAAXjR61XOWyX0l3evSYwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTkwNTI5MTYzNjAwWhcNMzkwNTI0MTYz\nNjAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABHiJekXiApSizb5ctC5JJ0r1EBXvuN5iXMSe3VM/d9rvnjzFozY7VRgALhHb\nAP3wxnnsVPX29JC2ZUlv6//U0LSjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBRUFwLEeWDMyZMC1QLrz1xhAyapuDAKBggqhkjO\nPQQDAgNJADBGAiEAqgyoSTtQxJ9RHnW2Zk7KsJthXSaoreN59vw+Ozp7XFACIQDB\n+tmtX3nGoeAf/np9j8oqvMNqApiPcxya8ToNSg/Otg==\n-----END CERTIFICATE-----\n",
"CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh",
"CertIssuerPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEeIl6ReIClKLNvly0LkknSvUQFe+43mJcxJ7dUz932u+ePMWjNjtVGAAuEdsA/fDGeexU9fb0kLZlSW/r/9TQtA=="
}
},
"Status": {
"State": "ready",
"Addr": "10.195.12.87"
},
"ManagerStatus": {
"Leader": true,
"Reachability": "reachable",
"Addr": "10.195.12.87:2377"
}
}
]

只是其中一个虚拟机:
PS C:\Docker\swarm-test> docker-machine inspect vm1
{
"ConfigVersion": 3,
"Driver": {
"IPAddress": "10.195.12.68",
"MachineName": "vm1",
"SSHUser": "docker",
"SSHPort": 22,
"SSHKeyPath": "C:\\Users\\19030430\\.docker\\machine\\machines\\vm1\\id_rsa",
"StorePath": "C:\\Users\\19030430\\.docker\\machine",
"SwarmMaster": false,
"SwarmHost": "tcp://0.0.0.0:3376",
"SwarmDiscovery": "",
"Boot2DockerURL": "",
"VSwitch": "thevswitch",
"DiskSize": 20000,
"MemSize": 1024,
"CPU": 1,
"MacAddr": "",
"VLanID": 0,
"DisableDynamicMemory": false
},
"DriverName": "hyperv",
"HostOptions": {
"Driver": "",
"Memory": 0,
"Disk": 0,
"EngineOptions": {
"ArbitraryFlags": [],
"Dns": null,
"GraphDir": "",
"Env": [],
"Ipv6": false,
"InsecureRegistry": [],
"Labels": [],
"LogLevel": "",
"StorageDriver": "",
"SelinuxEnabled": false,
"TlsVerify": true,
"RegistryMirror": [],
"InstallURL": "https://get.docker.com"
},
"SwarmOptions": {
"IsSwarm": false,
"Address": "",
"Discovery": "",
"Agent": false,
"Master": false,
"Host": "tcp://0.0.0.0:3376",
"Image": "swarm:latest",
"Strategy": "spread",
"Heartbeat": 0,
"Overcommit": 0,
"ArbitraryFlags": [],
"ArbitraryJoinFlags": [],
"Env": null,
"IsExperimental": false
},
"AuthOptions": {
"CertDir": "C:\\Users\\19030430\\.docker\\machine\\certs",
"CaCertPath": "C:\\Users\\19030430\\.docker\\machine\\certs\\ca.pem",
"CaPrivateKeyPath": "C:\\Users\\19030430\\.docker\\machine\\certs\\ca-key.pem",
"CaCertRemotePath": "",
"ServerCertPath": "C:\\Users\\19030430\\.docker\\machine\\machines\\vm1\\server.pem",
"ServerKeyPath": "C:\\Users\\19030430\\.docker\\machine\\machines\\vm1\\server-key.pem",
"ClientKeyPath": "C:\\Users\\19030430\\.docker\\machine\\certs\\key.pem",
"ServerCertRemotePath": "",
"ServerKeyRemotePath": "",
"ClientCertPath": "C:\\Users\\19030430\\.docker\\machine\\certs\\cert.pem",
"ServerCertSANs": [],
"StorePath": "C:\\Users\\19030430\\.docker\\machine\\machines\\vm1"
}
},
"Name": "vm1"
}
PS C:\Docker\swarm-test> get-hnsnetwork


ActivityId : F5EEF28D-7A66-410E-8F06-85417531C225
AdditionalParams :
CurrentEndpointCount : 0
Extensions : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=False; Name=Microsoft Azure VFP Switch Extension},
@{Id=EA24CD6C-D17A-4348-9190-09F0D5BE83DD; IsEnabled=True; Name=Microsoft NDIS Capture}}
Flags : 3
GatewayMac : 00-15-5D-0C-C5-08
Health : @{AddressNotificationMissedCount=0; AddressNotificationSequenceNumber=5; InterfaceNotificationMissedCount=0; InterfaceNotificationSequenceNumber=0; LastErrorCode=0; LastUpdateTime=132036146558887527;
RouteNotificationMissedCount=0; RouteNotificationSequenceNumber=0}
ID : C08CB7B8-9B3C-408E-8E30-5E16A3AEB444
IPv6 : False
IsolateSwitch : True
LayeredOn : 77DEBE34-C5AF-43EF-86C1-92F7CF9CD8EF
MacPools : {@{EndMacAddress=00-15-5D-0C-CF-FF; StartMacAddress=00-15-5D-0C-C0-00}}
MaxConcurrentEndpoints : 0
Name : Default Switch
NatName : ICS85DBD8A9-EEA6-4691-9FE4-901A4445B714
Policies : {}
Resources : @{AdditionalParams=; AllocationOrder=2; Allocators=System.Object[]; Health=; ID=F5EEF28D-7A66-410E-8F06-85417531C225; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0;
parentId=D841CDEC-707C-421C-BC2C-155F3F378A40}
State : 1
Subnets : {@{AdditionalParams=; AddressPrefix=192.168.55.32/28; GatewayAddress=192.168.55.33; Health=; ID=F7DEEC46-10E5-448D-B890-D78D93E6D560; Policies=System.Object[]; State=0}}
SwitchGuid : C08CB7B8-9B3C-408E-8E30-5E16A3AEB444
TotalEndpoints : 0
Type : ICS
Version : 38654705666

ActivityId : 6589B251-E629-4942-847F-DEE47853D5B6
AdditionalParams :
CurrentEndpointCount : 0
Extensions : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=False; Name=Microsoft Azure VFP Switch Extension},
@{Id=EA24CD6C-D17A-4348-9190-09F0D5BE83DD; IsEnabled=True; Name=Microsoft NDIS Capture}}
Flags : 0
Health : @{LastErrorCode=0; LastUpdateTime=132036158099689062}
ID : 07E7CCC7-187E-457B-A577-1EAFB16E9731
IPv6 : False
LayeredOn : 9108D862-FE98-4FE4-8004-2C210074F964
MacPools : {@{EndMacAddress=00-15-5D-B0-CF-FF; StartMacAddress=00-15-5D-B0-C0-00}}
MaxConcurrentEndpoints : 0
Name : thevswitch
Policies : {}
Resources : @{AdditionalParams=; AllocationOrder=0; Health=; ID=6589B251-E629-4942-847F-DEE47853D5B6; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0; parentId=CAEB6648-F50F-4C19-95D8-038C4E3B7346}
State : 1
TotalEndpoints : 0
Type : Transparent
Version : 38654705666

ActivityId : 7F5DFDB2-6E7E-497E-A33E-5BE5655DA57E
AdditionalParams :
CurrentEndpointCount : 0
Extensions : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=False; Name=Microsoft Azure VFP Switch Extension},
@{Id=EA24CD6C-D17A-4348-9190-09F0D5BE83DD; IsEnabled=True; Name=Microsoft NDIS Capture}}
Flags : 0
Health : @{AddressNotificationMissedCount=0; AddressNotificationSequenceNumber=0; InterfaceNotificationMissedCount=0; InterfaceNotificationSequenceNumber=0; LastErrorCode=0; LastUpdateTime=132036143540255829;
RouteNotificationMissedCount=0; RouteNotificationSequenceNumber=0}
ID : B242C9F9-89C0-4867-B14A-8A175A5D0DDB
IPv6 : False
LayeredOn : 80208A97-455B-4273-B95A-1E73666C9C52
MacPools : {@{EndMacAddress=00-15-5D-D9-8F-FF; StartMacAddress=00-15-5D-D9-80-00}}
MaxConcurrentEndpoints : 0
Name : nat
NatName : ICSBC687A8B-1FC0-4F10-A614-68EA68A3E2EF
Policies : {}
Resources : @{AdditionalParams=; AllocationOrder=2; Allocators=System.Object[]; Health=; ID=7F5DFDB2-6E7E-497E-A33E-5BE5655DA57E; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0;
parentId=7507FF2E-F59E-4B2C-8194-DDA947C5B5AE}
State : 1
Subnets : {@{AdditionalParams=; AddressPrefix=172.26.192.0/20; GatewayAddress=172.26.192.1; Health=; ID=B735AB8E-A2F9-4134-84BC-598A492F976A; Policies=System.Object[]; State=0}}
TotalEndpoints : 0
Type : nat
Version : 38654705666

Dockerfile:
version: "3"
services:
Hello:
image: registry.local:5000/wintest/swarm-test:2.0.0
ports:
-"8888:80"
deploy:
mode: global
PS C:\Docker\swarm-test> docker service ps test_Hello --no-trunc
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
27iw2nyi610g971bk0meeuf1h test_Hello.82vpc65ezml87sxhhx9mlvszk registry.local:5000/wintest/swarm-test:2.0.0 vm2 Ready Assigned less than a second ago
tw7ren3nakf0ukigjsqzrnkmf test_Hello.w2ftfwt4oz00keswt6ztmq9ec registry.local:5000/wintest/swarm-test:2.0.0 vm1 Ready Rejected less than a second ago "No such image: registry.local:5000/wintest/swarm-test:2.0.0"
xmdrc9102s4qjtstakrvh3msx test_Hello.4xiljuldm32avsxwo8o513uv5 registry.local:5000/wintest/swarm-test:2.0.0 ATLL000597 Ready Rejected 1 second ago "hnsCall failed in Win32: An adapter was not found. (0x803b0006)"
ezh203iv1ntj3w18wgqzdjceo test_Hello.lej0a3gabyi3qfta1f4le1f3s registry.local:5000/wintest/swarm-test:2.0.0 vm3 Running Rejected 4 seconds ago "No such image: registry.local:5000/wintest/swarm-test:2.0.0"
n3n4nfevoadawuqlusfbspg34 test_Hello.82vpc65ezml87sxhhx9mlvszk registry.local:5000/wintest/swarm-test:2.0.0 vm2 Shutdown Rejected 4 seconds ago "No such image: registry.local:5000/wintest/swarm-test:2.0.0"
t46s5etkwgumoa6jp22au3nq5 test_Hello.w2ftfwt4oz00keswt6ztmq9ec registry.local:5000/wintest/swarm-test:2.0.0 vm1 Shutdown Rejected 5 seconds ago "No such image: registry.local:5000/wintest/swarm-test:2.0.0"
rxwqbg2wndz4cdxw71k1d5ore test_Hello.4xiljuldm32avsxwo8o513uv5 registry.local:5000/wintest/swarm-test:2.0.0 ATLL000597 Shutdown Rejected 6 seconds ago "hnsCall failed in Win32: An adapter was not found. (0x803b0006)"
as92ats2qur5sr6e8lxflz71w test_Hello.lej0a3gabyi3qfta1f4le1f3s registry.local:5000/wintest/swarm-test:2.0.0 vm3 Shutdown Rejected 9 seconds ago "No such image: registry.local:5000/wintest/swarm-test:2.0.0"

引起我注意的是,检查虚拟机似乎表明它们不是群体的一部分,但它们是?
PS C:\Docker\swarm-test> docker-machine ssh vm1 "docker swarm init"
Error response from daemon: This node is already part of a swarm. Use "docker swarm leave" to leave this swarm and join another one.
exit status 1

此外,检查 Get-HNSNetwork 的事实显示 thevswitch是一个透明的网络。据我了解,我创建网络的方式应该使其显示为覆盖(用于驱动程序)或外部。在之前完成这些任务的尝试中,我以完全相同的方式创建了另一个 vswitch,但那个 vswitch 显示为私有(private)。我不明白如何遵循相同的步骤会产生两种不同且都不正确的结果。

这也是我的虚拟交换机管理器的屏幕截图:
V-Switch Manager

我已经阅读了 Docker 和 Windows 关于网络的各种文档,特别是覆盖网络,我感到非常迷茫。据我了解,这应该可以工作,并且我在网上发现的所有错误都指向同一个文档。我还没有看到任何让我认为这也做不到的事情。

任何帮助将不胜感激。

注意:第一次使用 Docker,试图组合一个成功的 PoC。我知道我的 docker-compose.yml不好看。与学习最佳实践相比,我花在学习 docker 网络上的时间更多。

最佳答案

对于遇到类似问题的任何人:

这个问题实际上与网络无关,就像这些隐含的错误消息一样。
问题实际上最终是 swarm 节点(但不是我的主机)都在使用 Linux 容器并试图提取仅 Windows 的图像。他们默默地抛出架构错误——我只是在尝试直接从节点中提取图像时才发现这一点。部署到整个 swarm 时产生的错误极具误导性。

我没有“解决”这个问题。我们最终围绕这个事实重新构建了我们的整个解决方案,但这种情况不再适用。

关于docker-swarm - 部署服务时如何修复 Docker 错误 "hnsCall failed in Win32: An adapter was not found"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56366762/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com