Docker Community Forums

Share and learn in the Docker community.

Connecting to containers IP address


(Cuchac) #1

Expected behavior

IP address of container will be available to host for connection

Actual behavior

Cannot access, no route to host


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

route add MASK

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:

(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 MASK

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

(Aaronjxz) #10

route add MASK

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 but not container
Docker for windows version: 17.12.0-ce

(Courudavance) #13

@abdujaparov Same to me !