Docker Community Forums

Share and learn in the Docker community.

IP Routing to container


(Carlskii) #1

Hi,

I created a new docker network like this:

docker network create --subnet 203.0.113.0/24 --gateway 203.0.113.254 iptastic

Then started a new container and assigned it to the new network with a fixed IP address like this:

docker run --net iptastic --ip 203.0.113.2 -d -P --name test_sshd eg_sshd

With regards to IP routing to the new container from my Mac OS, what interface is used by Docker for Mac for this ?


IP address given to container is not routable in bridge mode
Get access to xhyve Alpine VM ip and docker container ip from OSX
(Carlskii) #2

So adding to this question. This is my Docker network which shows a container attached with an IP address of 203.0.113.2. I can see in ifconfig an interface called bridge100 which has an ip address of 192.168.64.1.

Thus I would have expected that adding the following route:

route -n add 203.0.113.0/24 192.168.64.1 would allow me to connect to the containers IP address from my Mac. However that does not work. Am I missing something here ?

If I run Docker in virtualbox and do the same and add a route from my mac to the virtualbox interface it works.

[
{
“Name”: “iptastic”,
“Id”: “4419b3ebf7fe8539c2338a57acc1dec562500f06c8e144c9f77d00d26e228bec”,
“Scope”: “local”,
“Driver”: “bridge”,
“EnableIPv6”: false,
“IPAM”: {
“Driver”: “default”,
“Options”: {},
“Config”: [
{
“Subnet”: “203.0.113.0/24”,
“Gateway”: “203.0.113.254”
}
]
},
“Internal”: false,
“Containers”: {
“cc940a202eac3262b80308c3d793cc3007fdc0bd5b0c9570826aade2099ebe0e”: {
“Name”: “test_sshd”,
“EndpointID”: “cce8af1e05b75c47aeece32ae5cb0dc88700c7fcb89ed3cfcfdc4a1101ab0fb7”,
“MacAddress”: “02:42:cb:00:71:02”,
“IPv4Address”: “203.0.113.2/24”,
“IPv6Address”: “”
}
},
“Options”: {},
“Labels”: {}
}
]


(Cgcgbcbc) #3

same issue here, with the default bridge network


(Carlskii) #4

OK I did some more research and replicated each of the steps from my Mac on a Linux (Ubuntu) platform. Everything worked fine, I didn’t even need to add any routes and could connect to the docker container IP’s straight away. I then added a static route from my mac to the IP address of the Linux platform which then enabled me to connect from my Mac to the containers running on Linux.

So I guess there are still issues with networking on the Mac.


(Justin Cormack) #5

Yes we are aware of this (internal issue #2216).By default the bridge will not accept routes over it. Will update when we have decided how to resolve this.


Docker for mac beta not forwarding ports
(Lox99) #6

I ran into this too, our current development environment is counting on being able to route to 172.16.0.0/12 from OSX.


(Aleksijohansson) #7

Also having this issue and would definitely appreciate if it would be solved so that developing with Docker would be consistent on any platform including OS X. Keep up the good work!


Unable to connect to port 4243 on localhost
(Iamveen) #8

+1 This feature would be much appreciated.


(Chris Meyers) #9

+1 This feature would be much appreciated.

Where can I find/track internal issue #2216 ?


(Jamshid) #10

I don’t know if there is a public issue for internal issue 2216, but I filed a similar enhancement request on github:

I don’t know when/if Docker for Mac will give Mac processes direct access to containers by ip.

Until then I might switch back to docker-machine / VirtualBox. Hopefully “route” still works with docker 1.12 networking and swarm.


Connect directly to container
(Blunt1337) #11

+1 This feature would be much appreciated.


(Akbhargava) #12

+1 for this networking “feature”.

It appears that Docker knows about this issue: see “Known Limitations” at https://docs.docker.com/docker-for-mac/networking/

What I would like to understand is Docker’s strategy for this issue and some feedback on this channel so we can understand what to expect from Docker.


Support tap interface for direct container access (incl. multi-host)
(Davi) #13

+1 This feature would be much appreciated.


(Almirkadric) #14

This is the same as the following topic


(Almirkadric) #15

For those who haven’t yet got a working solution for this, I have created a shim workaround for this issue in this project. It behaves the exact same as the hvint0 interface on Windows

More details can be found here:

Honestly the fact this issue hasn’t been fixed is ridiculous so I plan to make some waves with this package. Request to update docs here:
docker/docker.github.io#3922

Please upvote and comment your support so that this issue gets the attention it deserves


Support tap interface for direct container access (incl. multi-host)