Skip to content

Proposal: Allow specifying a default gateway for bridge networking#9381

Merged
icecrime merged 1 commit intomoby:masterfrom
lebauce:default-gateway
Apr 20, 2015
Merged

Proposal: Allow specifying a default gateway for bridge networking#9381
icecrime merged 1 commit intomoby:masterfrom
lebauce:default-gateway

Conversation

@lebauce
Copy link
Copy Markdown
Contributor

@lebauce lebauce commented Nov 27, 2014

No description provided.

@SvenDowideit
Copy link
Copy Markdown
Contributor

Heya,

this needs documenting in both cli.md and networking.md, and I think you need to add some justification & explaination of what problems it solved to your pull request description.

@lebauce
Copy link
Copy Markdown
Contributor Author

lebauce commented Nov 28, 2014

Sure. I'll update the PR with the documentation.

Regarding the use case, we would like to run docker container with private IP adresses, but globally routable on our internal network, instead of the default private network allocated per docker host. We have tested the following options for the daemon:

--fixed-cidr=10.5.194.128/28 --ip-forward=false --ip-masq=false --iptables=false

The 10.5.194.128/28 is just an example of routable IP addresses on the integration network. Everything works fine (as long as you properly configure the docker0 bridge with a physical network device child), apart from the default gateway inside the container. This gateway is hard coded to be the hosts' IP address, which doesn't make sense in this case.

@lebauce
Copy link
Copy Markdown
Contributor Author

lebauce commented Dec 11, 2014

@SvenDowideit I modified the documentation, could you please take a look ? Thanks !

@SvenDowideit
Copy link
Copy Markdown
Contributor

Doc LGTM - @fredlf @jamtur01

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker

@cpuguy83
Copy link
Copy Markdown
Member

@lebauce In this case, you should either be setting --bip 10.5.194.129/28 or if you already have a bridge interface setup on the host, you can use --bridge <interface> instead of having Docker create one.

@ghost
Copy link
Copy Markdown

ghost commented Dec 15, 2014

@cpuguy83 please allow me to chime in, as I was the one who asked @lebauce to develop this feature. I'm not sure I understand what you propose though. Our goal is:

  • each docker host has an interface which belongs to a large, private network, which is globally routable in our infrastructure, say a /20
  • for each docker host, we reserve a part of this large network, say a /24
  • we take one of the ip addresses of this /24 and use it to configure the docker bridge; this address is not the default gateway for the large network
  • we use --fixed-cidr to let the docker daemon know that it's responsible for IP address allocation in this /24
  • we disable iptables altogether, and therefore source NATing and port NATing

We just need to let the containers know that the default gateway for the large network is not the address allocated to the docker bridge, which this patch does.

The pros of this approach are that the IP addresses "seen" by the containers are the same as the ones "seen" from the outside, which is important for applications that gossip (such as consul or cassandra). Also, we don't need to dynamically allocate ports, since each container has it's own globally routable address. And we don't need NATing at all.

If there's a way to do this using --bip or --bridge, I would be happy to know :)

@SvenDowideit SvenDowideit changed the title Allow specifying a default gateway for bridge networking Proposal: Allow specifying a default gateway for bridge networking Dec 16, 2014
@SvenDowideit
Copy link
Copy Markdown
Contributor

please ping me if this is closed because there is some other way to achieve it - we should document it if there is :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be: "... this IP address..." or simply "...this address..."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I also noticed that the "be" was missing.
Thanks !

@ghost
Copy link
Copy Markdown

ghost commented Dec 26, 2014

@SvenDowideit If there's another, existing, way to achieve what was described above, I would be happy to use it. I'm not sure if you are waiting for input from me or @cpuguy83 :)

@SvenDowideit
Copy link
Copy Markdown
Contributor

@eolamey its a note only in case, as its something we don't want to lose the documentation for - even if we need to re-write it.

@crosbymichael
Copy link
Copy Markdown
Contributor

This is good, i think we should do this. +1

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Mar 31, 2015

@eolamey At first I'm glad that you using --fixed-cidr :) I tried to merge it for very long time.
Design is okay for me, not a big deal.
ping @tiborvass for moving to code-review or questions

@icecrime
Copy link
Copy Markdown
Contributor

@lebauce Sorry for the crazy delay here: I'm pushing this to 2-code-review, are you please available to rebase your PR?

@thaJeztah
Copy link
Copy Markdown
Member

@icecrime @LK4D4 @crosbymichael I see IPv6 was added (as requested), so I think this can be reviewed

(@lebauce, correct me if you weren't ready yet)

@icecrime
Copy link
Copy Markdown
Contributor

@lebauce Sorry, it needs rebase again, and I promise we'll try to be reactive on review afterwards :-(

@lebauce
Copy link
Copy Markdown
Contributor Author

lebauce commented Apr 16, 2015

@icecrime Rebased, ready for review :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because they only manipulate net.IP and net.IPNet, I believe this code block (covering IPv6) and the one above (covering IPv4) can entirely be factored out in a function.

Not a blocker for merge considering that there's a death timer on this file anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Thanks

@icecrime
Copy link
Copy Markdown
Contributor

Thanks! Code LGTM (some duplication for IPv4 and IPv6 can be avoided, but I'm fine merging it nevertheless).

@cpuguy83
Copy link
Copy Markdown
Member

LGTM moving to docs review

@jamtur01
Copy link
Copy Markdown
Contributor

Docs LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mention eth0 twice in this sentence, but if i grok it right, the first time you're talking about the eth0 in the container, and the second one refers to the default network on the host.

on quite a few of my systems, I don't have an eth0 - RHEL seems to use some obfuscated device name.

So I would suggest making the first reference be explicit: eth0 in the container and the second could be changed to the host's default gateway

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both are taking about what gateway will be added to the eth0 interface in the container, the one from --default-gateway-v6 if specified, fe80::1 otherwise. Actually, the second reference to eth0 comes from the existing documentation. I'm not 100% though, as I don't know the IPv6 setup at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Both mentions of 'eth0' refer to the interface of the container. Removed the second reference to "eth0" and added "in the container".

Every new container will get an IPv6 address from the defined subnet. Further
a default route will be added on `eth0` in the container via the address
specified by the daemon option `--default-gateway-v6` if present, otherwise
via `fe80::1`:

Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
@lebauce
Copy link
Copy Markdown
Contributor Author

lebauce commented Apr 20, 2015

@icecrime I moved the common code to the "requestDefaultGateway" method. Thanks for pointing out the code duplication

@icecrime
Copy link
Copy Markdown
Contributor

Cool thanks!

icecrime pushed a commit that referenced this pull request Apr 20, 2015
Proposal: Allow specifying a default gateway for bridge networking
@icecrime icecrime merged commit 9838242 into moby:master Apr 20, 2015
@kgutwin kgutwin mentioned this pull request Jun 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.