Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electing Default Gateway within container is really opaque #784

Closed
fbuecklers opened this issue Nov 28, 2015 · 2 comments
Closed

Electing Default Gateway within container is really opaque #784

fbuecklers opened this issue Nov 28, 2015 · 2 comments

Comments

@fbuecklers
Copy link

I have created two bridges with the docker network API one bridged named local the other one is named isolated.

docker network create --driver bridge --subnet=172.17.0.0/16 -o com.docker.network.bridge.name=local local 
docker network create --driver bridge --subnet=172.28.0.0/16 -o com.docker.network.bridge.enable_ip_masquerade=false -o com.docker.network.bridge.name=isolated isolated

When I run a container with: docker run --rm -it --net=local busybox
and attach my isolated network afterward, i have the following routing table within the container:

/ # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.28.0.1      0.0.0.0         UG    0      0        0 eth1
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
172.28.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth1

so eth1 becomes the default gateway (the isolated bridge) which was not my attempt.
If i change the network attach order: starting in the isolated network and connecting to the local network my routing table results in:

/ # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.28.0.1      0.0.0.0         UG    0      0        0 eth0
172.28.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth1

So my gateway always ends in the isolated bridge. After a lot of try and error my founding is, that the default gateway is elected by the name order of the network. Naming my default network to allow_default solves the problem, but the solution seams really ugly.

@bboreham
Copy link
Contributor

bboreham commented May 4, 2016

Seems relevant: #1141 (comment)

@aboch
Copy link
Contributor

aboch commented Oct 3, 2016

Thanks @fbuecklers @bboreham
Given the logic is now documented, I will go ahead and close this issue.
Feel free to ocntinue the discussion, though.

@aboch aboch closed this as completed Oct 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants