【发布时间】:2019-07-16 17:41:10
【问题描述】:
错误报告信息
说明
无法从 Windows 10 上的容器内 ping docker-compose 服务。 ping 该服务的 IP 地址有效。
重现问题的步骤:
1 使用以下内容创建 docker-compose-quick-servers.yml
version: '3.4'
services:
server1:
image: mcr.microsoft.com/windows/nanoserver
container_name: Server_1
entrypoint: ping -t localhost
server2:
image: mcr.microsoft.com/windows/nanoserver
container_name: Server_2
entrypoint: ping -t localhost
networks:
default:
external:
name: nat
2 运行 docker 容器:docker-compose -f .\docker-compose-quick-servers.yml up -d
3 Ping 另一个 docker-compose 服务:docker exec Server_1 ping server2
描述您收到的结果: ping 失败。与第二个服务 IP 地址相同的操作可以正常工作。
描述您预期的结果: 我们应该能够使用其定义的名称 ping 服务。
您认为重要的其他信息(例如,问题只是偶尔发生): 它在我们的 prod 环境中运行良好(在 Windows Server 2016 上)。
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: false
docker info 的输出:
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 9
Server Version: 18.09.2
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)
Operating System: Windows 10 Enterprise Version 1803 (OS Build 17134.706)
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 15.93GiB
Name: H198818
ID: HOKO:5CAS:SIQ2:SCLD:3TB7:A6GG:EH5X:763G:CBV5:UQMJ:BGSO:PF2Y
Docker Root Dir: E:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: -1
Goroutines: 36
System Time: 2019-04-18T15:33:25.7898496-04:00
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
docker 检查两个容器 容器 1
[
{
"Id": "a187264b5df41392b85a6b0d465af14e0dae699893aa2bd7d325d3638ca37280",
"Created": "2019-07-19T15:41:58.0571535Z",
"Path": "ping",
"Args": [
"-t",
"localhost"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1180,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-07-22T13:10:28.0169558Z",
"FinishedAt": "2019-07-20T03:42:53.7800119-04:00"
},
"Image": "sha256:cf751d69394af7dc72bd2a251b5f206c623d58ad3c227b4eb38b7f78695fd6c6",
"ResolvConfPath": "",
"HostnamePath": "",
"HostsPath": "",
"LogPath": "C:\\ProgramData\\Docker\\containers\\a187264b5df41392b85a6b0d465af14e0dae699893aa2bd7d325d3638ca37280\\a187264b5df41392b85a6b0d465af14e0dae699893aa2bd7d325d3638ca37280-json.log",
"Name": "/Server_2",
"RestartCount": 0,
"Driver": "windowsfilter",
"Platform": "windows",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "nat",
"PortBindings": {},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 0,
"ConsoleSize": [
0,
0
],
"Isolation": "hyperv",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": null,
"ReadonlyPaths": null
},
"GraphDriver": {
"Data": {
"dir": "C:\\ProgramData\\Docker\\windowsfilter\\a187264b5df41392b85a6b0d465af14e0dae699893aa2bd7d325d3638ca37280"
},
"Name": "windowsfilter"
},
"Mounts": [],
"Config": {
"Hostname": "a187264b5df4",
"Domainname": "",
"User": "ContainerUser",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": null,
"Image": "mcr.microsoft.com/windows/nanoserver:1809",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"ping",
"-t",
"localhost"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "be02643ae0be24af8c209ead0232c7c323bce17485989dc12dfc691d5d5ec1b6",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "temp",
"com.docker.compose.service": "server2",
"com.docker.compose.version": "1.23.2"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "a187264b5df41392b85a6b0d465af14e0dae699893aa2bd7d325d3638ca37280",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "a187264b5df41392b85a6b0d465af14e0dae699893aa2bd7d325d3638ca37280",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"nat": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"server2",
"a187264b5df4"
],
"NetworkID": "a8c298597e4971959a217132aaf2521cdc5d0b3ce887580ad4239dce75f7e697",
"EndpointID": "edbb8a518b5be347f2c600864838bc850d8951a1e09a78b97f0fd0d67bf7a5d1",
"Gateway": "172.30.48.1",
"IPAddress": "172.30.57.127",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "00:15:5d:53:a2:da",
"DriverOpts": null
}
}
}
}
]
容器 2
[
{
"Id": "dca6e1b6e86c9e888f0c817c8f5677f6e9d1513ee67715b77f5ca134811ee2c0",
"Created": "2019-07-19T15:41:58.0571535Z",
"Path": "ping",
"Args": [
"-t",
"localhost"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1172,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-07-22T13:10:28.0179564Z",
"FinishedAt": "2019-07-20T03:42:53.7730133-04:00"
},
"Image": "sha256:cf751d69394af7dc72bd2a251b5f206c623d58ad3c227b4eb38b7f78695fd6c6",
"ResolvConfPath": "",
"HostnamePath": "",
"HostsPath": "",
"LogPath": "C:\\ProgramData\\Docker\\containers\\dca6e1b6e86c9e888f0c817c8f5677f6e9d1513ee67715b77f5ca134811ee2c0\\dca6e1b6e86c9e888f0c817c8f5677f6e9d1513ee67715b77f5ca134811ee2c0-json.log",
"Name": "/Server_1",
"RestartCount": 0,
"Driver": "windowsfilter",
"Platform": "windows",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "nat",
"PortBindings": {},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 0,
"ConsoleSize": [
0,
0
],
"Isolation": "hyperv",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": null,
"ReadonlyPaths": null
},
"GraphDriver": {
"Data": {
"dir": "C:\\ProgramData\\Docker\\windowsfilter\\dca6e1b6e86c9e888f0c817c8f5677f6e9d1513ee67715b77f5ca134811ee2c0"
},
"Name": "windowsfilter"
},
"Mounts": [],
"Config": {
"Hostname": "dca6e1b6e86c",
"Domainname": "",
"User": "ContainerUser",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": null,
"Image": "mcr.microsoft.com/windows/nanoserver:1809",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"ping",
"-t",
"localhost"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "39e91b8015a79dda2357d7e1af47455981a66b7d56d23b397d649f096e1b93f1",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "temp",
"com.docker.compose.service": "server1",
"com.docker.compose.version": "1.23.2"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "dca6e1b6e86c9e888f0c817c8f5677f6e9d1513ee67715b77f5ca134811ee2c0",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "dca6e1b6e86c9e888f0c817c8f5677f6e9d1513ee67715b77f5ca134811ee2c0",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"nat": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"server1",
"dca6e1b6e86c"
],
"NetworkID": "a8c298597e4971959a217132aaf2521cdc5d0b3ce887580ad4239dce75f7e697",
"EndpointID": "8825f5c168aeb39a022de1ab4cc0f0f5bdc5a1938d490a40d476182d96904791",
"Gateway": "172.30.48.1",
"IPAddress": "172.30.56.75",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "00:15:5d:53:ad:eb",
"DriverOpts": null
}
}
}
}
]
【问题讨论】:
标签: docker docker-compose