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

Improve network endpoints order, keep the interfaces order as it whether the container has been restarted or not #43518

Closed

Conversation

DrAuYueng
Copy link

@DrAuYueng DrAuYueng commented Apr 23, 2022

[Signed-off-by: DrAuYueng ouyang1204@gmail.com

Currently there is no way to keep the order for network endpoints , when we run a container with --network flag which referred a pre-created network and connect container to other networks one by one, like this:

docker network create -d bridge --subnet 172.28.0.0/16 mynet1

docker network create -d bridge --subnet 172.29.0.0/16 mynet2

docker run -tid --net mynet2 --name foo busybox

docker network connect mynet1 foo

Show ip info after connect network to container foo:

docker exec -ti foo ip a

ip info:


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0
515: eth0@if516: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
    link/ether 02:42:ac:1d:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.29.0.2/16 brd 172.29.255.255 scope global eth0
       valid_lft forever preferred_lft forever
517: eth1@if518: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
    link/ether 02:42:ac:1c:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.28.0.2/16 brd 172.28.255.255 scope global eth1
       valid_lft forever preferred_lft forever

It looks working well, but if restart the container, the interfaces order has been changed, like this:

docker restart foo

docker exec -ti foo ip a

ip info:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0
519: eth0@if520: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
    link/ether 02:42:ac:1c:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.28.0.2/16 brd 172.28.255.255 scope global eth0
       valid_lft forever preferred_lft forever
521: eth1@if522: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
    link/ether 02:42:ac:1d:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.29.0.2/16 brd 172.29.255.255 scope global eth1
       valid_lft forever preferred_lft forever

In addition, the default route for container has been changed too.

I would expect the networks to be assigned to interface in order and should be inconsistent after restarting container.

This PR improves network endpoints order, keep the interfaces order as it whether the container has been restarted or not.

Related issue: docker/compose#4645

@DrAuYueng DrAuYueng changed the title network endpoint join priority Make network endpoints join with priority. Apr 23, 2022
@DrAuYueng DrAuYueng changed the title Make network endpoints join with priority. Join network endpoints with priority Apr 24, 2022
@DrAuYueng DrAuYueng force-pushed the feature-endpoint-join-priority branch 3 times, most recently from d4437a4 to bd80fbd Compare April 27, 2022 09:08
@DrAuYueng
Copy link
Author

Follows moby/libnetwork#2132.

@thaJeztah thaJeztah added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. area/networking labels Apr 28, 2022
@DrAuYueng DrAuYueng force-pushed the feature-endpoint-join-priority branch from bd80fbd to c2efac0 Compare April 29, 2022 06:21
@DrAuYueng
Copy link
Author

Should fix #20179 as well.

@DrAuYueng DrAuYueng force-pushed the feature-endpoint-join-priority branch from a2f3960 to 9f33b2b Compare May 1, 2022 12:30
@DrAuYueng DrAuYueng changed the title Join network endpoints with priority Improve network endpoints order, keep the interfaces order as it whether the container has been restarted or not May 1, 2022
@DrAuYueng DrAuYueng force-pushed the feature-endpoint-join-priority branch from 57d0d9f to 3786cb3 Compare May 1, 2022 14:59
@DrAuYueng
Copy link
Author

@thaJeztah PTAL.

@DrAuYueng DrAuYueng force-pushed the feature-endpoint-join-priority branch 2 times, most recently from 8b282f9 to 36c1abe Compare May 2, 2022 12:50
@hhessel
Copy link

hhessel commented Aug 29, 2022

@DrAuYueng @thaJeztah Out of personal curiosity, is there a time plan to review and merge this? Thanks

@Vlad1mir-D
Copy link

Hello? :)

@DrAuYueng DrAuYueng closed this May 4, 2023
@DrAuYueng DrAuYueng force-pushed the feature-endpoint-join-priority branch from 36c1abe to 5c052e6 Compare May 4, 2023 13:56
@Vlad1mir-D
Copy link

Why closed?

@DrAuYueng
Copy link
Author

Misoperation, lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/networking kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants