Can't access docker from LAN - docker

I am running docker on my physic fedora machine.I started a prometheus container with host network, I think I should be able to access prometheus web pages from other host in the same local network, but failed.
My machina's ip is 172.31.209.112, the host I want to access prometheus is 172.31.1.195 on which I can ping 172.31.209.112. I can also confirm firewall is not running on both sides.
To access the LAN network I need to install a security software, which only has windows version, so I installed a windows vm with network set to NAT to cheat the security software, but I don't think this have something to do with my docker accessing problem.
I can access prometheus with localhost:9090 or 172.31.209.112:9090 locally, but just can't access it from any hosts in LAN, please help.
here is my docker container config:
{
"Id": "88b4c38e6a659754e861976b6b8b11d1dff495db1ef3d572169065a2e0acf4f6",
"Created": "2019-07-03T10:06:59.61293669Z",
"Path": "/bin/prometheus",
"Args": [
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
"--web.console.libraries=/usr/share/prometheus/console_libraries",
"--web.console.templates=/usr/share/prometheus/consoles"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 5687,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-07-03T10:06:59.836329996Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:5d62a6125e7e0121151c24f6ec132bfae02cc37a2b57a666fd0569bed66d498f",
"ResolvConfPath": "/var/lib/docker/containers/88b4c38e6a659754e861976b6b8b11d1dff495db1ef3d572169065a2e0acf4f6/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/88b4c38e6a659754e861976b6b8b11d1dff495db1ef3d572169065a2e0acf4f6/hostname",
"HostsPath": "/var/lib/docker/containers/88b4c38e6a659754e861976b6b8b11d1dff495db1ef3d572169065a2e0acf4f6/hosts",
"LogPath": "/var/lib/docker/containers/88b4c38e6a659754e861976b6b8b11d1dff495db1ef3d572169065a2e0acf4f6/88b4c38e6a659754e861976b6b8b11d1dff495db1ef3d572169065a2e0acf4f6-json.log",
"Name": "/elastic_kapitsa",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/home/ggfan/4-tmp/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "host",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/d1e89e203e0a0791e370911f07f112a56603be51af65c29fc679b0c78350d4bf-init/diff:/var/lib/docker/overlay2/64e3d0a748213274b8210bde9f849e09e40aa59214cec724f0ef3167ed0d8030/diff:/var/lib/docker/overlay2/197e352b2464399aef2da8a75f31cb78179c3ad7b7e03b517176694fca19e7bc/diff:/var/lib/docker/overlay2/2a601b39acac1f8054c28af2d68004611ee17417c82d9c12842fc1b4725d18f5/diff:/var/lib/docker/overlay2/3590491c1df9eb9d1f4272abad88a6ad44f7f7e169129b8a6bdbba8a02fca09f/diff:/var/lib/docker/overlay2/0b1a049f0c204896187f0a3050a43eeb7d226fd0bfa810149f689039215d0068/diff:/var/lib/docker/overlay2/8c3523f1a5d77616be86ca76850c2cb682728c9d349032c0809781e3a9f24839/diff:/var/lib/docker/overlay2/b95196ec6ef2ed89345e6ecda9c476a30266a14097ca3931169159e01d5610b8/diff:/var/lib/docker/overlay2/56f16ca07e36898774523cb9d17bb5fc4d9c6526579bc3d764d257c41970e5bb/diff:/var/lib/docker/overlay2/749405b668264446ef9ec29a24089b5ce7dc7b9363033afab5dfa765ad1980e6/diff",
"MergedDir": "/var/lib/docker/overlay2/d1e89e203e0a0791e370911f07f112a56603be51af65c29fc679b0c78350d4bf/merged",
"UpperDir": "/var/lib/docker/overlay2/d1e89e203e0a0791e370911f07f112a56603be51af65c29fc679b0c78350d4bf/diff",
"WorkDir": "/var/lib/docker/overlay2/d1e89e203e0a0791e370911f07f112a56603be51af65c29fc679b0c78350d4bf/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/home/ggfan/4-tmp/prometheus/prometheus.yml",
"Destination": "/etc/prometheus/prometheus.yml",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "volume",
"Name": "833a1e3a523e0e3061f937ef9868413342ba9277c079b8f3bab5d363a884aa44",
"Source": "/var/lib/docker/volumes/833a1e3a523e0e3061f937ef9868413342ba9277c079b8f3bab5d363a884aa44/_data",
"Destination": "/prometheus",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "localhost.localdomain",
"Domainname": "",
"User": "nobody",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"9090/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
"--web.console.libraries=/usr/share/prometheus/console_libraries",
"--web.console.templates=/usr/share/prometheus/consoles"
],
"ArgsEscaped": true,
"Image": "prom/prometheus",
"Volumes": {
"/prometheus": {}
},
"WorkingDir": "/prometheus",
"Entrypoint": [
"/bin/prometheus"
],
"OnBuild": null,
"Labels": {
"maintainer": "The Prometheus Authors <prometheus-developers#googlegroups.com>"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "5029bdc13e1f15aebb36e2d5a84c6d34f2d078360705a577946f92268b59a37e",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/default",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"host": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "d58749e2d0012b4e59f12097a590b4814258fad4a99252a21df1c2863f5ca03b",
"EndpointID": "7238756953fc7ea91d9364c17a7730658f2057b583508bd1ea8ebcbffd1f6ab5",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
my network:
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:10ff:fe57:b91 prefixlen 64 scopeid 0x20<link>
ether 02:42:10:57:0b:91 txqueuelen 0 (Ethernet)
RX packets 33469 bytes 5113347 (4.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 40202 bytes 4779129 (4.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.31.209.112 netmask 255.255.255.0 broadcast 172.31.209.255
inet6 fe80::7ab9:b4e3:e089:36e3 prefixlen 64 scopeid 0x20<link>
ether 18:66:da:45:1f:63 txqueuelen 1000 (Ethernet)
RX packets 2448716 bytes 386681103 (368.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 761559 bytes 192020136 (183.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xf7180000-f71a0000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 256361 bytes 332219233 (316.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 256361 bytes 332219233 (316.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth19c1c5e: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::e80f:ccff:fefb:f2a1 prefixlen 64 scopeid 0x20<link>
ether ea:0f:cc:fb:f2:a1 txqueuelen 0 (Ethernet)
RX packets 83 bytes 285072 (278.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5896 bytes 1195103 (1.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth4586d02: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::24c6:88ff:fe1b:41ea prefixlen 64 scopeid 0x20<link>
ether 26:c6:88:1b:41:ea txqueuelen 0 (Ethernet)
RX packets 39 bytes 2718 (2.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6957 bytes 1410747 (1.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:2c:67:b9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0-nic: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 52:54:00:2c:67:b9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vmnet1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.131.1 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::eb22:59d6:882e:9200 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:c0:00:01 txqueuelen 1000 (Ethernet)
RX packets 14178 bytes 0 (0.0 B)
RX errors 0 dropped 9 overruns 0 frame 0
TX packets 6603 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
and my routes:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 enp0s31f6
link-local 0.0.0.0 255.255.0.0 U 101 0 0 vmnet1
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.31.0.0 _gateway 255.255.0.0 UG 100 0 0 enp0s31f6
172.31.209.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s31f6
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
224.0.0.0 0.0.0.0 240.0.0.0 U 101 0 0 vmnet1

Related

Containers unable to communicate on same EC2 host

I have a multi-container application deployed on an EC2 instance via a single ECS task. When I try making an HTTP request to container-2 from container-1, I get error "Name or service not known."
I'm unable to reproduce this locally when I run with docker compose. I'm using the bridge network mode. I've SSH'd into the EC2 instance and can see that both containers are on the bridge network. (I've unsuccessfully tried awsvpc as well and that led to a different set of issues... so I'll save that for a separate post if necessary.)
Here's a snippet of my task-definition.json:
{
...
"containerDefinitions": [
{
"name": "container-1",
"image": "container-1",
"portMappings": [
{
"hostPort": 8081,
"containerPort": 8081,
"protocol": "tcp"
}
]
},
{
"name": "container-2",
"image": "container-2",
"portMappings": [
{
"hostPort": 8080,
"containerPort": 8080,
"protocol": "tcp"
}
]
}
],
"networkMode": "bridge",
...
}
EDIT1 - Adding some of my ifconfig, let me know if I need to add more.
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:a7ff:febd:55df prefixlen 64 scopeid 0x20<link>
ether 02:42:a7:bd:55:df txqueuelen 0 (Ethernet)
RX packets 842 bytes 55315 (54.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 614 bytes 78799 (76.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ecs-bridge: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 169.254.172.1 netmask 255.255.252.0 broadcast 0.0.0.0
inet6 fe80::c5a:1bff:fed4:525f prefixlen 64 scopeid 0x20<link>
ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23 bytes 1890 (1.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 3760 bytes 274480 (268.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3760 bytes 274480 (268.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
EDIT2 - docker inspect bridge
[
{
"Name": "bridge",
"Id": "...",
"Created": "...",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "XXX",
"Gateway": "XXX"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"somehash": {
"Name": "container-1",
"EndpointID": "XXX",
"MacAddress": "XXX",
"IPv4Address": "XXX",
"IPv6Address": ""
},
"somehash": {
"Name": "container-2",
"EndpointID": "XXX",
"MacAddress": "XXX",
"IPv4Address": "XXX",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
To allow containers in a single task, in EC2 host networking mode, to communicate with each other you need to specify the links attribute to map containers to internal network names. This is documented here.

Why can't I access to my container from host directly across your IP?

So this is my problem:
I have some docker containers running in my host. One of then is gitlab/gitlab-ce. When I try to access across your IP from my host http://172.17.0.4 which is your IP, I can to access but with this plantuml-server I try the same and I can't do it. Your IP is http://172.17.0.3.
Here is the inspection information.
GitLab
[
{
"Id": "8babbd53aa3c27a2887889a5ee84e096a18a175fbadb3cdd614b553b0f389a81",
"Created": "2022-12-23T17:39:39.16626421Z",
"Path": "/assets/wrapper",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 304598,
"ExitCode": 0,
"Error": "",
"StartedAt": "2022-12-23T17:39:39.568194523Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:9918f6cf4187ab5c5f0e45096bd23a25e5db8b781db20769307dfc261ec2b755",
"ResolvConfPath": "/var/lib/docker/containers/8babbd53aa3c27a2887889a5ee84e096a18a175fbadb3cdd614b553b0f389a81/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/8babbd53aa3c27a2887889a5ee84e096a18a175fbadb3cdd614b553b0f389a81/hostname",
"HostsPath": "/var/lib/docker/containers/8babbd53aa3c27a2887889a5ee84e096a18a175fbadb3cdd614b553b0f389a81/hosts",
"LogPath": "/var/lib/docker/containers/8babbd53aa3c27a2887889a5ee84e096a18a175fbadb3cdd614b553b0f389a81/8babbd53aa3c27a2887889a5ee84e096a18a175fbadb3cdd614b553b0f389a81-json.log",
"Name": "/gitlab-sgdev",
"RestartCount": 0,
"Driver": "btrfs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/srv/gitlab/logs:/var/log/gitlab:Z",
"/srv/gitlab/data:/var/opt/gitlab:Z",
"/srv/gitlab/config:/etc/gitlab:Z"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"22/tcp": [
{
"HostIp": "",
"HostPort": "222"
}
],
"443/tcp": [
{
"HostIp": "",
"HostPort": "443"
}
],
"80/tcp": [
{
"HostIp": "",
"HostPort": "7001"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 268435456,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": null,
"Name": "btrfs"
},
"Mounts": [
{
"Type": "bind",
"Source": "/srv/gitlab/logs",
"Destination": "/var/log/gitlab",
"Mode": "Z",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/srv/gitlab/data",
"Destination": "/var/opt/gitlab",
"Mode": "Z",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/srv/gitlab/config",
"Destination": "/etc/gitlab",
"Mode": "Z",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "8babbd53aa3c",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"22/tcp": {},
"443/tcp": {},
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/opt/gitlab/embedded/bin:/opt/gitlab/bin:/assets:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"EDITOR=/bin/vi",
"TERM=xterm"
],
"Cmd": [
"/assets/wrapper"
],
"Healthcheck": {
"Test": [
"CMD-SHELL",
"/opt/gitlab/bin/gitlab-healthcheck --fail --max-time 10"
],
"Interval": 60000000000,
"Timeout": 30000000000,
"Retries": 5
},
"Image": "gitlab/gitlab-ce:latest",
"Volumes": {
"/etc/gitlab": {},
"/var/log/gitlab": {},
"/var/opt/gitlab": {}
},
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "abb40e02b058359e9ca5ca7aca20a9268fc6f5638f291b6c6ab8d00123e007be",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"22/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "222"
},
{
"HostIp": "::",
"HostPort": "222"
}
],
"443/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "443"
},
{
"HostIp": "::",
"HostPort": "443"
}
],
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "7001"
},
{
"HostIp": "::",
"HostPort": "7001"
}
]
},
"SandboxKey": "/var/run/docker/netns/abb40e02b058",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "5ee193802d07e47ba688d6b2f0a6e6e7dc3349393491d00b5b5c33c9c5e0d5c3",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:04",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "ee0faa9d62174552279ad681ae602e497908ddb98b1b88e7252c8ad43fcb292a",
"EndpointID": "5ee193802d07e47ba688d6b2f0a6e6e7dc3349393491d00b5b5c33c9c5e0d5c3",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:04",
"DriverOpts": null
}
}
}
}
]
PlantUML
[
{
"Id": "8dbee44f840fef635538045f26552be152a44c55a76d9a0dbe4fc885e0f00b97",
"Created": "2022-07-16T08:04:03.653555888Z",
"Path": "/entrypoint.sh",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1525,
"ExitCode": 0,
"Error": "",
"StartedAt": "2022-12-22T23:38:44.120843112Z",
"FinishedAt": "2022-12-22T23:38:09.484902602Z"
},
"Image": "sha256:e6c6321a6cc7a3c8e194521ca9f72dbaefd78cc5ae6cd6b2b0391f68ea10b892",
"ResolvConfPath": "/var/lib/docker/containers/8dbee44f840fef635538045f26552be152a44c55a76d9a0dbe4fc885e0f00b97/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/8dbee44f840fef635538045f26552be152a44c55a76d9a0dbe4fc885e0f00b97/hostname",
"HostsPath": "/var/lib/docker/containers/8dbee44f840fef635538045f26552be152a44c55a76d9a0dbe4fc885e0f00b97/hosts",
"LogPath": "/var/lib/docker/containers/8dbee44f840fef635538045f26552be152a44c55a76d9a0dbe4fc885e0f00b97/8dbee44f840fef635538045f26552be152a44c55a76d9a0dbe4fc885e0f00b97-json.log",
"Name": "/plantuml-sgdev",
"RestartCount": 0,
"Driver": "btrfs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"8080/tcp": [
{
"HostIp": "",
"HostPort": "7000"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": null,
"Name": "btrfs"
},
"Mounts": [],
"Config": {
"Hostname": "8dbee44f840f",
"Domainname": "",
"User": "jetty",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/jetty/bin:/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"JAVA_HOME=/usr/local/openjdk-11",
"LANG=C.UTF-8",
"JAVA_VERSION=11.0.14",
"JETTY_VERSION=11.0.7",
"JETTY_HOME=/usr/local/jetty",
"JETTY_BASE=/var/lib/jetty",
"TMPDIR=/tmp/jetty",
"JETTY_TGZ_URL=https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/11.0.7/jetty-home-11.0.7.tar.gz",
"JETTY_GPG_KEYS=AED5EE6C45D0FE8D5D1B164F27DED4BF6216DB8F \t2A684B57436A81FA8706B53C61C3351A438A3B7D \t5989BAF76217B843D66BE55B2D0E1FB8FE4B68B4 \tB59B67FD7904984367F931800818D9D68FB67BAC \tBFBB21C246D7776836287A48A04E0C74ABB35FEA \t8B096546B1A8F02656B15D3B1677D141BCF3584D \tFBA2B18D238AB852DF95745C76157BDF03D0DCD6 \t5C9579B3DB2E506429319AAEF33B071B29559E1E \tF254B35617DC255D9344BCFA873A8E86B4372146",
"BASE_URL=ROOT",
"WEBAPP_PATH=/var/lib/jetty/webapps"
],
"Cmd": null,
"Image": "plantuml/plantuml-server:jetty",
"Volumes": null,
"WorkingDir": "/var/lib/jetty",
"Entrypoint": [
"/entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"org.opencontainers.image.created": "2022-06-22T07:51:34.609Z",
"org.opencontainers.image.description": "PlantUML Online Server",
"org.opencontainers.image.licenses": "GPL-3.0",
"org.opencontainers.image.revision": "dd028e95790cbf56154b747dda74ba36dc78b8d9",
"org.opencontainers.image.source": "https://github.com/plantuml/plantuml-server",
"org.opencontainers.image.title": "plantuml-server",
"org.opencontainers.image.url": "https://github.com/plantuml/plantuml-server",
"org.opencontainers.image.version": "v1.2022.6"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "447cee5734c178db114ab951228c82c71b6a5e1da9d23617a295909df73e7dc1",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "7000"
},
{
"HostIp": "::",
"HostPort": "7000"
}
]
},
"SandboxKey": "/var/run/docker/netns/447cee5734c1",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "24ef8e6fab0668c414a43628a97731008e545137aeade4b3d0517de648afdcca",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "ee0faa9d62174552279ad681ae602e497908ddb98b1b88e7252c8ad43fcb292a",
"EndpointID": "24ef8e6fab0668c414a43628a97731008e545137aeade4b3d0517de648afdcca",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
}
}
}
}
]
I ping the containers and it works
❯ ping -c 4 172.17.0.3
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from 172.17.0.3: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from 172.17.0.3: icmp_seq=3 ttl=64 time=0.031 ms
64 bytes from 172.17.0.3: icmp_seq=4 ttl=64 time=0.030 ms
--- 172.17.0.3 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3034ms
rtt min/avg/max/mdev = 0.030/0.034/0.045/0.006 ms
❯ ping -c 4 172.17.0.4
PING 172.17.0.4 (172.17.0.4) 56(84) bytes of data.
64 bytes from 172.17.0.4: icmp_seq=1 ttl=64 time=0.031 ms
64 bytes from 172.17.0.4: icmp_seq=2 ttl=64 time=0.029 ms
64 bytes from 172.17.0.4: icmp_seq=3 ttl=64 time=0.030 ms
64 bytes from 172.17.0.4: icmp_seq=4 ttl=64 time=0.029 ms
--- 172.17.0.4 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3034ms
rtt min/avg/max/mdev = 0.029/0.029/0.031/0.000 ms
This is my /etc/hosts file
#
# Static table lookup for hostnames.
# See hosts(5) for details.
#
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# GitLab-Self
172.17.0.4 gitlab.sg
# PlantUML
172.17.0.3 plantuml.sg
When I try to access via http://gitlab.sg it works for gitlab container.
but I try to access via http://plantuml.sg it not works for plantuml container.
Some idea to resolve this issue.
Thanks.

Cannot resolve docker-compose services hostnames on Windows 10

BUG REPORT INFORMATION
Description
Cannot ping docker-compose service from within a container on Windows 10.
Pinging the IP address of that service works.
Steps to reproduce the issue:
1 Create docker-compose-quick-servers.yml with the following content
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 Run the docker containers: docker-compose -f .\docker-compose-quick-servers.yml up -d
3 Ping the other docker-compose service: docker exec Server_1 ping server2
Describe the results you received:
The ping fail. The same operation with the second service IP address works fine.
Describe the results you expected:
We should be able to ping services using its defined name.
Additional information you deem important (e.g. issue happens only occasionally):
It works fine in our prod environment (on Windows Server 2016).
Output of 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
Output of 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 inspect for both containers
container 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
}
}
}
}
]
container 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 CE is not recommended for Windows Server. Use Docker EE Basic, it's free for Windows Servers.
Update:
In general your configuration looks ok... aliases are set, but from the ping output I see it's not a problem of pinging, but dns resolution. Second container is using some external dns to resolve server1 instead using docker internal dns.
There's a similar bug report touching docker dns resolution for windows containers: https://github.com/docker/for-win/issues/1976
This might be your case.
As temporary solution I'd recommend you to set up dns resolvers in containers to default docker dns at 127.0.0.11 (https://docs.docker.com/v17.09/engine/userguide/networking/configure-dns/)
update 2:
I reproduced on Win1809 and it works for me:
PS E:\workspace\docker-test> docker-compose up -d
Pulling server1 (mcr.microsoft.com/windows/nanoserver:1809)...
1809: Pulling from windows/nanoserver
58fd16eaae0b: Pull complete
Pulling server2 (mcr.microsoft.com/windows/nanoserver:1809)...
1809: Pulling from windows/nanoserver
Creating Server_1 ... done
Creating Server_2 ... done
PS E:\workspace\docker-test> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0628c2fd7106 mcr.microsoft.com/windows/nanoserver:1809 "ping -t localhost" 12 seconds ago Up 6 seconds Server_1
8e52138080f2 mcr.microsoft.com/windows/nanoserver:1809 "ping -t localhost" 12 seconds ago Up 6 seconds Server_2
PS E:\workspace\docker-test> docker exec Server_2 ping Server_1
Pinging Server_1 [172.27.195.21] with 32 bytes of data:
Reply from 172.27.195.21: bytes=32 time<1ms TTL=128
Reply from 172.27.195.21: bytes=32 time=5ms TTL=128
PS E:\workspace\docker-test> docker exec Server_1 ping Server_2
Pinging Server_2 [172.27.193.166] with 32 bytes of data:
Reply from 172.27.193.166: bytes=32 time<1ms TTL=128
Reply from 172.27.193.166: bytes=32 time=1ms TTL=128
PS E:\workspace\docker-test> docker exec Server_2 ping server1
Pinging server1 [172.27.195.21] with 32 bytes of data:
Reply from 172.27.195.21: bytes=32 time=1ms TTL=128
Reply from 172.27.195.21: bytes=32 time=2ms TTL=128
PS E:\workspace\docker-test> docker exec Server_1 ping server2
Pinging server2 [172.27.193.166] with 32 bytes of data:
Reply from 172.27.193.166: bytes=32 time<1ms TTL=128
Reply from 172.27.193.166: bytes=32 time=4ms TTL=128

customizing docker bridge network

I want my docker0 and all containers to have the same gateway address or be in the same IPrange as my local machine. I started by defining a fixed-cidr in ther daemon.json file /etc/docker/daemon.json
{
"bip": "10.80.44.248/24",
"fixed-cidr": "10.80.44.250/25",
"mtu": 1500,
"default-gateway": "10.80.44.254",
"dns": ["10.80.41.14"]
}
It seems to be working looking at the output of the ip -a
It seems the docker0 has never received any data since.
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet *10.80.44.248* netmask 255.255.255.0 broadcast *10.80.44.255*
ether 02:42:9c:b9:e1:63 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet *10.80.44.39* netmask 255.255.255.0 broadcast *10.80.44.255*
inet6 fe80::250:56ff:feb1:79e4 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:b1:79:e4 txqueuelen 1000 (Ethernet)
RX packets 211061 bytes 30426474 (29.0 MiB)
RX errors 0 dropped 33861 overruns 0 frame 0
TX packets 3032 bytes 260143 (254.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The local machine and the docker0 are in same IP range with the same gateway. Good.
But when I start the docker containers and inspected the bridge settings Everything was different. This is the output of
docker network inspect bridge
[
{
"Name": "bridge",
"Id": "b326a37a589245449e1268bbb9ee65262eb7986574c0e972c56d350aa82d7238",
"Created": "2018-04-04T03:25:52.00544539+02:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "10.80.44.248/24",
"IPRange": "10.80.44.128/25",
"Gateway": "10.80.44.248",
"AuxiliaryAddresses": {
"DefaultGatewayIPv4": "10.80.44.254"
}
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
I don't understand why now IPAM config is having a IPv4 als auxiliary
"AuxiliaryAddresses": {
"DefaultGatewayIPv4": "10.80.44.254"
}
I realised that now the bridge is not created from the same subnet as it was configured by the daemon I it created 2 different bridges with different IP ranges. That is still the default from docker.
docker network ls
NETWORK ID NAME DRIVER SCOPE
b326a37a5892 bridge bridge local
6ce11066cdea dockergitlab_default bridge local
d5a36c04b809 host host local
15f66b88ee67 none null local
docker network inspect dockergitlab_default
[
{
"Name": "dockergitlab_default",
"Id": "6ce11066cdeabf3cfe65b2dff22046bd1e9c18d2588f47b9cd3c52ea24f7a636",
"Created": "2018-03-14T08:56:23.351051727+01:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"60f769c91cff1de47794a7c8b587b778488883da094ae32cfde5196ee0f528f1": {
"Name": "gitlab-runner",
"EndpointID": "5122fe862537fb8434a484b4797153274b945e20bc3c7223efc6fd0bd55eae14",
"MacAddress": "02:42:ac:11:00:04",
"IPv4Address": "172.17.0.4/16",
"IPv6Address": ""
},
"9c46e1fde6390142bddf67270cfeda7b3e68b1a6e68cabc334046db687240a8d": {
"Name": "dockergitlab_postgresql_1",
"EndpointID": "8488b32cc34a2c92308528de74b5eddcecac12a402ee6e67c1ef0f2750b72721",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"eaf29f5f405cbf9bdd918efad26ceae1a8c3f58f4bef0aa8fd86b4631bcfdf43": {
"Name": "dockergitlab_gitlab_1",
"EndpointID": "d7f78ee9bd51dd13826d7834470d03a9084fc7ab8c6567c0181acecc221628c6",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
},
"f460687ec00eff214fa08adfe9a0af5b85c392ceb470c4ed630ef7ecb0bfcba1": {
"Name": "dockergitlab_redis_1",
"EndpointID": "8b18906f1c79a5faaadd32afdef20473f9b635e9a1cd2c7108dd98df48eaed86",
"MacAddress": "02:42:ac:11:00:05",
"IPv4Address": "172.17.0.5/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "dockergitlab"
}
}
]
I have no idea why the docker bridge is now created with the old default ip address.
LOCAL SYSTEM Details
I can do apt update on the local machine but when i logged into the gitlab-runner i can't do apt update
Linux 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64
Docker version 17.12.0-ce, build c97c6d6
docker-compose version 1.18.0, build 8dd22a9
Is there a way I can oveeride the bridge settings. From what i have read, when I define/configure the cdir and gateway in daemon.json file everything will be taken from there for the creation of the bridge network and all other containers.
Thanks in Advance for your help.
First of all you've correctly configured the docker0 bridge and starting containers with the plain docker run command should connect them to the bridge and give them IPs in 10.80.44.250/25.
From what you've pasted I guess you're using docker-compose to start your containers.
docker-compose will create a myproject_default network per docker-compose.yml if you don't specify anything.
Today you cannot choose in which pool the IP ranges will be chosen, it's by default a 172.[17-31].0.0/16. There is currently an active pull request to allow override of this behaviour : https://github.com/moby/moby/pull/36396.
If you want to manually specify the IP range in your docker-compose.yml you can write this :
networks:
default:
ipam:
config:
- subnet: 10.80.44.250/25
Edit : this is only compatible with a docker-compose syntax >=3.0.

Container running but cannot be visited in browser

I followed http://containertutorials.com/docker-compose/flask-compose.html and have a running container.
$ docker-compose up
Starting flaskcomposedockerexample_web_1
Attaching to flaskcomposedockerexample_web_1
web_1 | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
web_1 | * Restarting with stat
web_1 | * Debugger is active!
$ docker logs d66ca374c99a
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 249-821-232
Going to browser or curl will not connect:
This site can’t be reached
127.0.0.1 refused to connect.
$ curl 127.0.0.1:5000
curl: (7) Failed to connect to 127.0.0.1 port 5000: Connection refused
Why would a container with no errors not be able to be visited?
$ netstat
Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 142.25.150.89.57766 stackoverflow.co.https ESTABLISHED
tcp4 0 0 142.25.150.89.56837 8.36.126.32.http ESTABLISHED
tcp4 0 0 localhost.56800 localhost.56800 ESTABLISHED
tcp4 0 0 localhost.56801 localhost.56801 ESTABLISHED
$ docker inspect d66ca374c99a
[
{
"Id": "d66ca374c99afb13a2bee56fa44fd73f4c39569edcf8c50f175bf5a124a57a73",
"Created": "2017-04-18T14:08:54.859932607Z",
"Path": "python",
"Args": [
"app.py"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 14402,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-04-18T14:09:28.342011012Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:1b3ceada8dd91e8a4403e7ee001b7a4832f72120162f8788651c3301f5ccfa89",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/d66ca374c99afb13a2bee56fa44fd73f4c39569edcf8c50f175bf5a124a57a73/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/d66ca374c99afb13a2bee56fa44fd73f4c39569edcf8c50f175bf5a124a57a73/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/d66ca374c99afb13a2bee56fa44fd73f4c39569edcf8c50f175bf5a124a57a73/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/d66ca374c99afb13a2bee56fa44fd73f4c39569edcf8c50f175bf5a124a57a73/d66ca374c99afb13a2bee56fa44fd73f4c39569edcf8c50f175bf5a124a57a73-json.log",
"Name": "/flaskcomposedockerexample_web_1",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/Users/cchilders/flask_compose_docker_example:/code:rw"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"5000/tcp": [
{
"HostIp": "",
"HostPort": "5000"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"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": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"Mounts": [
{
"Type": "bind",
"Source": "/Users/cchilders/flask_compose_docker_example",
"Destination": "/code",
"Mode": "rw",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "d66ca374c99a",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"5000/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"app.py"
],
"ArgsEscaped": true,
"Image": "flaskcomposedockerexample_web",
"Volumes": {
"/code": {}
},
"WorkingDir": "/app",
"Entrypoint": [
"python"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "3c65c28cc5926f591068f82a4d028ae50573b14ac4059ebe17b196be2185995a",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "flaskcomposedockerexample",
"com.docker.compose.service": "web",
"com.docker.compose.version": "1.11.2"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "6b4cd91f76cb21f70fc7b1b17e403f21ef790cc1e02fee5547740ac5192229fe",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "5000"
}
]
},
"SandboxKey": "/var/run/docker/netns/6b4cd91f76cb",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "e05d8bf26815734a146d6f4b1fb803b365629dfce732a2b21993970a33e54a80",
"Gateway": "162.16.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "162.16.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:bd:55:00:04",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "2fd3c33ec08105cd00de10ab5555554572bac4548866239aa375e8df60ed3aa",
"EndpointID": "e05d8bf26815734a146d6f4b1fb80555559dfce732a2b21993970a33e54a80",
"Gateway": "162.16.0.1",
"IPAddress": "162.16.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:44:00:04"
}
}
}
}
]
$ netstat -tnlp
netstat: option requires an argument -- p
Usage: netstat [-AaLlnW] [-f address_family | -p protocol]
netstat [-gilns] [-f address_family]
netstat -i | -I interface [-w wait] [-abdgRtS]
netstat -s [-s] [-f address_family | -p protocol] [-w wait]
netstat -i | -I interface -s [-f address_family | -p protocol]
netstat -m [-m]
netstat -r [-Aaln] [-f address_family]
netstat -rs [-s]
$ netstat -tnpl
netstat: l: unknown or uninstrumented protocol
There are two problems. First the tutorial you are referring to has syntax error in the first line of app.py, it should be
from flask import Flask
Secondly, Docker works differently in Mac and Windows. Docker doesn't directly map the ports to the local host; instead of that Docker creates a very small Linux virtual machine which is approximately 24 mb in size and then run containers inside that this virtual machine which is also called docker machine. So instead of mapping the ports to localhost, Docker maps it to docker machine so your containers should be accessible to
http://docker_machine_ip:port_no
Instead of
http://localhost:port_no
The default docker machine IP address can be found using:
docker-machine ip dev

Resources