-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[BUG] eth0 default route priority define outbound connection #12170
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
these are some of the other threads on this #4645 this seems like a longstanding issue |
|
@mrpops2ko Could you share you network definitions please? |
the other networks are all created upon docker compose startup |
i tried playing around with the routing from within the container but nothing seems to work
i even included
and that still didn't allow me to do it, so yeah i'm kind of at a loss on how |
I'm having a very similar problem: a bridge network and an ipvlan network are attached to a container, the ipvlan gets set as the default route when I need it to be the bridge network. Networks are defined as follow:
And the for the container:
The defined order as no impact on the default route, neither does the alphanumerical order. |
AFAICT this is a docker engine issue. Let me know if you find a way to get the expected result by a combination of |
Every time a container is connected to a network, Docker Engine looks at the container's whole set of endpoints and picks one to use as the gateway. (And, the same after a network disconnect.) The gateway endpoint it picks is the first in this ordering. I don't think that function's comment is quite right... but, endpoints are sorted by priority, then the dedicated That means the order in which networks are connected shouldn't make any difference to the end result:
But, in the two examples above - the networks are all equal (user-defined, non-internal, and IPv4-only). So, they should be sorted by network name ... I've tried to repro the problem, but haven't been able to. For me, the selected gateway is always based on the network name - including with dockerd 24.0, I don't think this logic has changed since before that release anyway. I don't think there's anything compose can do to affect this. If we make the engine's priority field useful, we may need to add way for compose to specify it - but we can come back to that. @mrpops2ko, please could you re-raise this in https://github.com/moby/moby/issues? (Unfortunately we can't move issues between projects.) Then we can dig in to it some more ... I think I'll need a minimal repro, if possible. |
hi @robmry thank you for this detailed explanation, and it is working as you've described it, the problem is that people have many use case scenarios where they don't want it to work as you described. A > B works and is great but there are scenarios where A < B are required or wanted. can you explain more about this some parts from reading your comment seem contradictory maybe thats the delineation? i'm assuming that the first endpoint with the highest priority would result in becoming the eth0 default gateway for internet connectivity, would that be your assumption and understanding too? that isn't the case as to what is happening and reading through the older bug threads, priority was never seemingly designed to do that #11229 (comment) |
priority (as seen in https://github.com/moby/moby/blob/c14efb8deeb2cf5a716ab874c707f9a69228926c/libnetwork/sandbox.go#L677-L683) used to sort endpoints is not set by Docker Compose as API. So the result is you get sort applied by name (https://docs.docker.com/reference/api/engine/version/v1.45/#tag/Network/operation/NetworkConnect) does not offer such an option - I wonder this is a swarm-only feature ?
|
Hi @mrpops2ko - yes, understood ... only having the network name to determine gateway selection isn't good. But, network name is influencing gateway selection for you now, including for ipvlan? In your original description, you said "2. that it is based upon the alphabetic naming of the networks, so A will begin before B etc (this seems to be true for customer docker networks, but it doesn't work similarly when combined with ipvlan networks)". As far as I can see, the rule should apply equally to ipvlan and bridge networks - and I wasn't able to repro the problem, for me the name of the network always determined the gateway selection, all other things being equal. I'm reluctant to make any changes without understanding this, it'd be easy to break something that's relied on by others.
As @ndeloof says, it's just the order in which compose connects networks. For the engine - I think it'll affect interface naming in the containers, they're numbered in order (
Right. As I said, "The epPriority used in the engine's ordering of endpoints is unrelated and, weirdly, there's no way to configure it via the engine's API. (So, it's completely useless.)" ... it doesn't work, don't try to make more sense of it than that!
I tried to describe my understanding in my last comment, and it's not that. But, I agree more control is needed. I don't think we'd want to reuse compose's priority field to set the gateway priority in future ... there might be a reason to connect the gateway endpoint last, or to want interface numbering to be separate from gateway selection. So, there's some missing plumbing, we need a way to be able to specify gateway priority for the engine. But, if the network name isn't currently having the expected effect, I'd like to understand that. However, this isn't a compose issue. So, I've raised moby/moby#48868 ... let's continue the discussion over there. (@ndeloof, please could you close this one?) |
Description
hi i've been reading through all the documentation and i'm struggling on how to define which networks in docker compose become the default gateway
from googling i can find various resources which say that its;
I stumbled across a few different issues here which talked about priority and i thought that i could use that to define which network becomes the default outbound gateway but that doesn't appear to be the case either, i'm not sure what priority does - from reading the bug thread it mentioned it was something in relation to mac addresses.
Steps To Reproduce
take for example this, br0 is an ipvlan network and the other 2 are custom docker networks
my use case scenario is that i want to have as eth0 the br0 interface. the reason for this is because i wish to do split tunnelling on the router and in order to do that i need ipvlan.
it works fine if i remove the other custom networks, but i can't for the life of me seem to be able to get the ipvlan br0 network to become the default eth0 network whilst using docker custom networks alongside it
one possible solution to this seems to be creating a container init script and running that on load, which will change the default route to the desired one but i think this is not a very clean solution compared to a native implementation which docker compose
Compose Version
Docker Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: