-
Notifications
You must be signed in to change notification settings - Fork 18.8k
control network interface order for containers #40974
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
control network interface order for containers #40974
Conversation
Signed-off-by: fanjiyun <fan.jiyun@zte.com.cn>
It depends on vendor moby/libnetwork#2550. |
Any updates? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok.
Hunting through libnetwork this is poorly documented it seems like this is used to sort endpoints when adding them and as a key when deleting
I'd prefer if priority were set based on order of joins, unfortunately the API specifies this in a map which we cannot sort.
I'm curious what the need for priority is? Is this just to control interface names? It may be better to just provide a way to customize the name.
I also think the naming is a little confusing.
In any case, if we do add this we'll need the field to be added to the api docs.
https://github.com/moby/moby/blob/master/api/swagger.yaml
Also a doc string on the type would be helpful.
In addition to controlling the interface names, the order of endpoint joins may have something to do with which interface's gateway becomes the default gateway for the container. @neersighted and I were just talking about default gateways last week! I would also prefer allowing interface names, and which interface is the default gateway, to be set explicitly over doing it in a roundabout fashion with priority. |
The related ticket was for controlling the interface name when joining a network. At the time it was created, we didn't have per-network options, but with the advanced sytax that was added, at least the UX would now allow it; One thing to look into for that is that currently the API does not allow multiple networks to be specified when creating a container. This effectively is an "artificial" limitation; it was blocked at the time because the UX didn't allow for this, but the CLI already was updated to support it. I asked @akerouanton to look if there's actual technical reasons remaining to not allow it (and if not, to remove that error, and support it). |
This was implemented in #48936, so let me close this PR. Thanks for your contribution! |
Signed-off-by: fanjiyun fan.jiyun@zte.com.cn
- What I did
libnetwork allows setting the priority of network interface, but I'm not sure why there's no api to support it. So, I made some changes to allow the user to control the network interface order for containers.
related issue: #25181
Relevant PRs:
moby/libnetwork#2550 (open)
docker/cli#2529(open)
- How I did it
add some options for docker create, docker run, docker network connect. i.e.,
$ docker create --network name=my-network,priority=1 mynginx
$ docker run --network name=my-network,priority=2 mynginx
$ docker network connect --priority 3 my-network my-container
priority deafult to 0, and the higher the value, the higher the priority of the network interface
- How to verify it
network interface order: net3 > net2 > net1
or
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)