Docker Community Forums

Share and learn in the Docker community.

Accessing a container's IP from a Windows 10 (Surface Pro 4) machine


(Tonycarreira) #1

For a few days now I’ve been having difficulty accessing a RabbitMQ container from my host machine (Windows 10 on a Surface Pro 4).

These were my steps:
Installed Docker for windows
Enabled Hyper-V and Containers in Windows features

Installed docker tool box (btw can you have docker tool box and hyper-v in the same machine without causing conflicts? I need the tool box because I use the docker-machine command).

PS C:\Users\fmigu> docker version
Client:
Version: 1.13.0
API version: 1.25
Go version: go1.7.3
Git commit: 49bf474
Built: Wed Jan 18 16:20:26 2017
OS/Arch: windows/amd64

Server:
Version: 1.13.0
API version: 1.25 (minimum version 1.12)
Go version: go1.7.3
Git commit: 49bf474
Built: Wed Jan 18 16:20:26 2017
OS/Arch: linux/amd64
Experimental: true

docker run rabbitMQ

docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5f3c1461a8ae rabbitmq “docker-entrypoint…” 41 seconds ago Up 40 seconds 4369/tcp, 5671-5672/tcp, 25672/tcp keen_stallman

docker inspect 5f3c1461a8ae

[
{
“Id”: “5f3c1461a8aebc256da31193bbc0c331cb24b23b1f13d62d19d23dee43f21777”,
“Created”: “2017-02-03T11:14:05.2347201Z”,
“Path”: “docker-entrypoint.sh”,
“Args”: [
“rabbitmq-server”
],
“State”: {
“Status”: “running”,
“Running”: true,
“Paused”: false,
“Restarting”: false,
“OOMKilled”: false,
“Dead”: false,
“Pid”: 2943,
“ExitCode”: 0,
“Error”: “”,
“StartedAt”: “2017-02-03T11:14:06.0080448Z”,
“FinishedAt”: “0001-01-01T00:00:00Z”
},
“Image”: “sha256:ec798eba2c56853d5f4ef9d06d6772736ae3a988f0326926780125d30e889f6f”,
“ResolvConfPath”: “/var/lib/docker/containers/5f3c1461a8aebc256da31193bbc0c331cb24b23b1f13d62d19d23dee43f21777/resolv.conf”,
“HostnamePath”: “/var/lib/docker/containers/5f3c1461a8aebc256da31193bbc0c331cb24b23b1f13d62d19d23dee43f21777/hostname”,
“HostsPath”: “/var/lib/docker/containers/5f3c1461a8aebc256da31193bbc0c331cb24b23b1f13d62d19d23dee43f21777/hosts”,
“LogPath”: “/var/lib/docker/containers/5f3c1461a8aebc256da31193bbc0c331cb24b23b1f13d62d19d23dee43f21777/5f3c1461a8aebc256da31193bbc0c331cb24b23b1f13d62d19d23dee43f21777-json.log”,
“Name”: “/keen_stallman”,
“RestartCount”: 0,
“Driver”: “overlay2”,
“MountLabel”: “”,
“ProcessLabel”: “”,
“AppArmorProfile”: “”,
“ExecIDs”: null,
“HostConfig”: {
“Binds”: null,
“ContainerIDFile”: “”,
“LogConfig”: {
“Type”: “json-file”,
“Config”: {}
},
“NetworkMode”: “default”,
“PortBindings”: {},
“RestartPolicy”: {
“Name”: “no”,
“MaximumRetryCount”: 0
},
“AutoRemove”: false,
“VolumeDriver”: “”,
“VolumesFrom”: null,
“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”: 67108864,
“Runtime”: “runc”,
“ConsoleSize”: [
50,
120
],
“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”: [],
“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”: {
“Name”: “overlay2”,
“Data”: {
“LowerDir”: “/var/lib/docker/overlay2/ee3de6aaa5fcb2df04a9cf982b5d20d4970d28deed76dca219dd362f357d5366-init/diff:/var/lib/docker/overlay2/f37901295da664af539cbef54cb807774fb2cb33bcfa7821b74e63deadba8d27/diff:/var/lib/docker/overlay2/ecc91f6315fa587f12ef4704a61c5e7b9956811bb677f8b58317dd9bcc0fb07d/diff:/var/lib/docker/overlay2/6aef5e5135b6bb1d0d29a86e89ef6c7a0539c68fb3642acf666b395badfba207/diff:/var/lib/docker/overlay2/1aded6f964537e2b5cb657d66fee42b27d0585bf5a68b9732d92415b22b9c3fe/diff:/var/lib/docker/overlay2/896ccec9d55fab17ab22dbcbf2a5ae231ff02b7f177bf0fa0c7e8bcb88b691db/diff:/var/lib/docker/overlay2/13bf566543e4838f20ddc57556a8c4743b6dc46f66f19ff496ec013b3fed1bfc/diff:/var/lib/docker/overlay2/07fe3afb697bef0d28071178e79830cdbd80aac0bf865259b90cbca63cedffd1/diff:/var/lib/docker/overlay2/e819d4bfa26d5c187b8432ee99c4be95fa2cf779aea4d23bc9e5ac77cc5051b8/diff:/var/lib/docker/overlay2/ee9ace9780e33761fde2c65e7a9d4b1844283d3e068456fab6a328161748c362/diff:/var/lib/docker/overlay2/4f8f06915685dc7b0cb37bd429c1d34f9f3e49b1efb75594477c198384dfc5cd/diff:/var/lib/docker/overlay2/ed2894ca054ec16e3b6932127eedac6cf65587527fe8721a2ae3f7aba255a5a3/diff:/var/lib/docker/overlay2/e33cfa8dee063bf10752e7b6690b4f02c84b9c1d41dc4208104d1898d2860063/diff:/var/lib/docker/overlay2/9ce9af9d43d72c901d610bf30a41148a0b59c930b008f4765ac137524a7f2ae8/diff:/var/lib/docker/overlay2/64d2c071d7214d12a97a1f58a1e62a64d78504ea777c7d92b3dac91ac825eff9/diff”,
“MergedDir”: “/var/lib/docker/overlay2/ee3de6aaa5fcb2df04a9cf982b5d20d4970d28deed76dca219dd362f357d5366/merged”,
“UpperDir”: “/var/lib/docker/overlay2/ee3de6aaa5fcb2df04a9cf982b5d20d4970d28deed76dca219dd362f357d5366/diff”,
“WorkDir”: “/var/lib/docker/overlay2/ee3de6aaa5fcb2df04a9cf982b5d20d4970d28deed76dca219dd362f357d5366/work”
}
},
“Mounts”: [
{
“Type”: “volume”,
“Name”: “21abcd1f8c4def230abca43667de1072f6b4cce5ff19843411786073a1055d2d”,
“Source”: “/var/lib/docker/volumes/21abcd1f8c4def230abca43667de1072f6b4cce5ff19843411786073a1055d2d/_data”,
“Destination”: “/var/lib/rabbitmq”,
“Driver”: “local”,
“Mode”: “”,
“RW”: true,
“Propagation”: “”
}
],
“Config”: {
“Hostname”: “5f3c1461a8ae”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: true,
“AttachStderr”: true,
“ExposedPorts”: {
“25672/tcp”: {},
“4369/tcp”: {},
“5671/tcp”: {},
“5672/tcp”: {}
},
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/lib/rabbitmq/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”,
“GOSU_VERSION=1.7”,
“RABBITMQ_LOGS=-”,
“RABBITMQ_SASL_LOGS=-”,
“RABBITMQ_VERSION=3.6.6”,
“RABBITMQ_DEBIAN_VERSION=3.6.6-1”,
“HOME=/var/lib/rabbitmq”
],
“Cmd”: [
“rabbitmq-server”
],
“ArgsEscaped”: true,
“Image”: “rabbitmq”,
“Volumes”: {
"/var/lib/rabbitmq": {}
},
“WorkingDir”: “”,
“Entrypoint”: [
docker-entrypoint.sh
],
“OnBuild”: null,
“Labels”: {}
},
“NetworkSettings”: {
“Bridge”: “”,
“SandboxID”: “c43465d34fe22475399c155511e1a42344ed91245bbd46f629397a4635b0df1e”,
“HairpinMode”: false,
“LinkLocalIPv6Address”: “”,
“LinkLocalIPv6PrefixLen”: 0,
“Ports”: {
“25672/tcp”: null,
“4369/tcp”: null,
“5671/tcp”: null,
“5672/tcp”: null
},
“SandboxKey”: “/var/run/docker/netns/c43465d34fe2”,
“SecondaryIPAddresses”: null,
“SecondaryIPv6Addresses”: null,
“EndpointID”: “216bc5803449117b346cf30eef361889f7cd9d406c7f4de113831014832219c1”,
“Gateway”: “172.17.0.1”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“MacAddress”: “02:42:ac:11:00:02”,
“Networks”: {
“bridge”: {
“IPAMConfig”: null,
“Links”: null,
“Aliases”: null,
“NetworkID”: “fd932cbfdf6cd349a784df9cce38e12c7ea2c1c7a011a63c14445615113456c9”,
“EndpointID”: “216bc5803449117b346cf30eef361889f7cd9d406c7f4de113831014832219c1”,
“Gateway”: “172.17.0.1”,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“MacAddress”: “02:42:ac:11:00:02”
}
}
}
}
]

telnet 172.17.0.2 5672
Connecting To 172.17.0.2…Could not open connection to the host, on port 5672: Connect failed

ping 172.17.0.2
Pinging 172.17.0.2
Request timed out.

I’ve tried some recommended advice I found on similar topics such as

route add 172.x.x.x. mask 255.255.255.0 etc… without success.

losing my mind here! :stuck_out_tongue: Help!


(Michael Friis) #2

Docker for Windows comes with docker-machine (just don’t try to use to create virtualbox-backed local machines). Docker for Windows and Toolbox are not compatible, so you have to choose one or the other.

When you run containers with Docker for Windows (not Toolbox) and use -p to expose ports, the service will be available on localhost on the host.


(Tonycarreira) #3

Thanks for the reply Friism. To me it does not work. I ran:
docker run -p 5672 --name myRabbitMQ rabbitmq

telnet localhost 5672
Unable to connect


(Michael Friis) #4

Is that using Docker for Windows or Docker Toolbox? It doesn’t work that way with Toolbox. Here’s the Docker for Windows docs:


(Tonycarreira) #5

Docker for windows mate. I just can’t connect, telnet, ping neither localhost 5672 nor 172.17.0.2 (docker ip of the container). I’ve just formated my machine as well. I tried adding the route to 10.72.0.2 without success also.


(Michael Friis) #6

That sounds strange - could you create an issue with diagnostics here: https://github.com/docker/for-win/issues/new


(Tonycarreira) #7

Sure thing mate, just did it.


(Artisticcheese) #8

Disable any firewall on your host.


(Nicolas Bihan) #9

What is the result of running?
docker ps -a


(Breandandalton) #10

When trying to expose a port, I found that I had to run it like this:

docker run -p 5672:5672 --name myRabbitMQ rabbitmq