-
Notifications
You must be signed in to change notification settings - Fork 880
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
Support for com.docker.network.host_ipv4 driver label #2454
Conversation
|
This commit allows a user to specify a Host IP via the com.docker.network.host_ipv4 label which is used as the Source IP during SNAT for bridge networks . The use case is for hosts with multiple interfaces and this label can dictate which IP will be used as Source IP for North-South traffic In the absence of this label, MASQUERADE is used which picks the Source IP based on Next Hop from the Route Table Addresses: moby/moby#30053 Signed-off-by: Arko Dasgupta <[email protected]>
f311af4
to
98ff1b5
Compare
This feature would be great! |
Any updates on this? :) |
Why is other stuff getting merged and not this? |
ping @suwang48404 @euanh |
@Mattzi @itouch5000 @P4sca1 any thoughts for a better label name ? |
@arkodg Im not an expert when it comes to networking and interfaces, but afaik one interface can have multiple ip addresses assigned. In that case we would have the same issue of not being able to define the outgoing ip. |
good catch @P4sca1 |
@arkodg Anything else that needs to be considered before this one can get merged? |
Sorry for ping but |
Now that the changes are approved, is there any chance of merging the changes? @arkodg |
@P4sca1 we usually look for two LGTMs before we merge, a review from you would be appreciated :) |
Alright, good to know. |
Great to see this merged! Thank you @arkodg 😁 |
This should get vendored into moby/moby soon and is a likely candidate for the 20.03/20.04 major docker-ce release |
full diff: moby/libnetwork@feeff4f...6659f7f includes: - moby/libnetwork#2317 Allow bridge net driver to skip IPv4 configuration of bridge interface - adds support for a `com.docker.network.bridge.inhibit_ipv4` label/configuration - addresses moby#37430 Prevent bridge network driver from setting IPv4 address on bridge interface - moby/libnetwork#2454 Support for com.docker.network.host_ipv4 driver label - addresses moby#30053 Unable to choose outbound (external) IP for containers - moby/libnetwork#2491 Improving load balancer performance - addresses moby#35082 [SWARM] Very poor performance for ingress network with lots of parallel requests Signed-off-by: Sebastiaan van Stijn <[email protected]>
This PR adds a testcase for the com.docker.network.host_ipv4 label commited via moby/libnetwork#2454 Signed-off-by: Arko Dasgupta <[email protected]>
This PR adds a testcase for the com.docker.network.host_ipv4 label commited via moby/libnetwork#2454 Signed-off-by: Arko Dasgupta <[email protected]> Upstream-commit: 2e0762ae44ba631c6943297413728f4daac89563 Component: engine
is this functionality not possible for ipv6? |
Is this PR already in the current release? I've been trying to get it working, but it seems to be ignored completely, and I'm having a hard time finding what libnetwork features are in what Docker releases, as
|
Any plan on making it possible to set this per container too? Like we have |
Please, I need to give each container an external IP, the only way I can see this happening is by creating a new network for each container. Considering I have a /28 subnet that means 14 different networks |
Ha, cute, I'm doing 254 separate docker networks on my /24. |
Damn, and I was thinking of writing a script to automate it lol I think something like this would be better
and then
when |
I can't get this solution to actually work anyways, my host requires that the IPs are statically routed through the main ip of the server, because of this, the gateway must be the first ip in the subnet. But if i have to create a new network for each ip in a subnet I don't see how I can do so without each one being in a /32 subnet, and in this case the gateway ip is not accessible as it is outside of the subnet.. |
@SharkWipf how do you set up your networks? what command do you use, I still haven't figured out how to create one for each ip yet |
@MrBenFTW while this is getting out of scope for comments on a pull request, I'm currently using a fairly hacky script that I run whenever I need to build a container, that checks if a network for the IP already exists, and if not, creates it with a manually specified subnet per network (necessary for my use case, might not be necessary for yours). Then I just assign said network to the container(s) afterwards. if ! (( $(docker network ls -qf "name=network.${ip_new}$" | wc -l) )); then
docker network create --driver bridge \
--subnet "10.10.${ip_new##*.}.1/24" \
--gateway "10.10.${ip_new##*.}.1" \
--opt "com.docker.network.host_ipv4=${ip_new}" \
"network.${ip_new}"
fi |
Is it deployed in docker-ce 20.10? There seems to be no mention of it in the release note? |
@SharkWipf Actually there's a much better way of doing it... Create network
Create containers |
@MrBenFTW Your method, I believe, only works if you don't need outbound connections (or at least I couldn't get it working with outbound connections in my quick testing), whereas this PR specifically applies to outbound connections. |
Nope. This specifically applies to inbound and outbound connections. If I do Everything is working perfectly now. My mail server resolves to the correct RDNS |
Hello everyone, my environment is: a server has multiple public IP addresses. I want dockers to use the host mode, and then each docker can specify a different exit IP address. Is it possible? thank you! |
If you use the host mode, then the docker does nothing with your networking. Your process has to bind to a proper interface. |
@thaJeztah @arkodg did this make into any release of docker-ce / engine? It is not mentioned in any of the release notes. If not, when is this planned? Thanks for clarifying |
@mendorf-ebf yes, looks like it was included in docker 20.10 through moby/moby#40579, but missed in the changelog (at a quick glance); https://docs.docker.com/engine/release-notes/#20100 |
This commit allows a user to specify a Host IP via the
com.docker.network.host_ipv4 label which is used as the
Source IP during SNAT for bridge networks .
The use case is for hosts with multiple interfaces and
this label can dictate which IP will be used as Source IP
for North-South traffic
In the absence of this label, MASQUERADE is used which picks the Source IP
based on Next Hop from the Route Table
Addresses: moby/moby#30053
Signed-off-by: Arko Dasgupta [email protected]