Docker Community Forums

Share and learn in the Docker community.

Connecting to containers IP address

beta

(Cuchac) #1

Expected behavior

IP address of container will be available to host for connection

Actual behavior

Cannot access, no route to host

Information

By default dockerNAT assigns 10.0.75.0/24 to MobyLinuxVM.
Docker inside MobyLinuxVM assigns to containers IP addresses in range 172.17.0.0/16. You have to alter route tables to access containers IP address:

route add  172.17.0.0 MASK 255.255.0.0 10.0.75.2

Steps to reproduce the behavior

  1. create container
  2. discover containers IP address
  3. ups … cannot ping that address

(Michael Friis) #2

Thanks for reporting. We’re aware of these limitations and are working on improvements.


(Rschiefer) #3

Is this still a problem? I seem to also have this issue but the “route add” doesn’t fix it for me.


(Harneet463) #4

In fact I have a completely opposite problem.
I started a SQL Server 2016 express container and the SQL Server instance is visible and accessible from all the machine s except the host machine.
I tries all the combinations of hostname\SQLexpress but to no avail.
Then I found out the conatiner address and tried connecting to it and it worked.
Still confused. though.


(Michael Friis) #5

You might want to check out this: https://blog.sixeyed.com/published-ports-on-windows-containers-dont-do-loopback/


(Whitecolor) #6

I think this is related question (or the same) Access container from dev machine (by ip/dns name)


(Whitecolor) #7

Does it have some relation to Original question?


(Whitecolor) #8

route /P add 172.0.0.0 MASK 255.0.0.0 10.0.75.2

works for me, I can now access 172.x.x.x from dev machine


(Aaronjxz) #10

route add 172.17.0.0 MASK 255.255.0.0 10.0.75.2

works too, the -p is for persistence


(Whitecolor) #11

It won’t work in the latest version.


(Abdujaparov) #12

route add does not resolve in my situation.
I can ping gateway 172.17.0.1 but not container 172.17.0.3.
Docker for windows version: 17.12.0-ce


(Courudavance) #13

@abdujaparov Same to me !