Skip to content

Vendor in Libnetwork changes#41805

Merged
tiborvass merged 1 commit into
moby:masterfrom
arkodg:vendor-libnetwork-ipv6-port-forwarding
Dec 23, 2020
Merged

Vendor in Libnetwork changes#41805
tiborvass merged 1 commit into
moby:masterfrom
arkodg:vendor-libnetwork-ipv6-port-forwarding

Conversation

@arkodg

@arkodg arkodg commented Dec 15, 2020

Copy link
Copy Markdown
Contributor

Brings in moby/libnetwork#2604
fixes #41822 "Upgrade to 20.10 fails to release ports published to IPv6 literal addresses"

Brings in moby/libnetwork#2604

Signed-off-by: Arko Dasgupta <[email protected]>
@arkodg
arkodg requested a review from tianon as a code owner December 15, 2020 18:23
@nightah

nightah commented Dec 21, 2020

Copy link
Copy Markdown

Am I correct in understanding that this should resolve #41822?

@arkodg

arkodg commented Dec 22, 2020

Copy link
Copy Markdown
Contributor Author

yes @nightah this PR should solve your issue

@arkodg

arkodg commented Dec 22, 2020

Copy link
Copy Markdown
Contributor Author

PTAL @tiborvass @thaJeztah

@gamma

gamma commented Aug 5, 2021

Copy link
Copy Markdown

The solution of this issue has created a problem - at least on my -side: creating a container with option -P or -p 80 assigns both, IPv4 and IPv6 ports of the host to the container. Previously (version 20.10.1) it only assigned an IPv4 address.

On occasions it assigns these automatic ports to different port numbers on IPv4 and IPv6 - see https://forums.docker.com/t/why-different-port-number-is-mapped-on-ipv4-and-ipv6-address-for-same-expose-port/109795

This is a problem - at least when using the classic swarm - which seems to think that the IPv6 port is an IPv4 port. When the ports are not in sync it occurs, that, when several container with this issue are created, the IPV4 ports overlap on the swarm endpoint.

Long story short: before 20.10.2 there was no automatic IPv6 assignment using -P or -p 80. Now there is. Is that intended behavior? If so: how can it be disabled without loosing IPv6 inside the container?

@thaJeztah

Copy link
Copy Markdown
Member

Older releases implicitly bound ports on both IPv4 and IPv6. 20.10 includes that information in the API.

This is a problem - at least when using the classic swarm - which seems to think that the IPv6 port is an IPv4 port.

That's unlikely to be fixed, with classic swarm being deprecated.

for the IPv4 and IPv6 ports not being the same when using random / ephemeral port assignment, there's this ticket; #42442 (feel free to participate in the discussion there; contributions welcome as well of course 😅)

Not sure if it helps as a workaround, but if you know which ports should be mapped, you can use 0.0.0.0 as the host IP address, and have an ephemeral/random port assigned (leave out the <host-port> in the <ip-address>:<host-port>:<container-port> format). This should make the port only published on IPv4;

docker run -d -p 0.0.0.0::80 --name foobar nginx:alpine

docker port foobar 80
0.0.0.0:49155

@gamma

gamma commented Aug 5, 2021

Copy link
Copy Markdown

Thanks for the elaborate explanation! I did not know about the -p 0.0.0.0::80 syntax even though I'm using docker since its beginning 🤣 - it might help me indeed.

I'll also check the mentioned issue!

@thaJeztah

Copy link
Copy Markdown
Member

Yeah, the -p shorthand syntax is unfortunately quite complex. The -P / --publish-all option can be "convenient", but in general, I recommend being explicit about which container ports must be published. The -P option automatically creates a port-mapping based on metadata of the container (EXPOSE). The EXPOSE metadata is just metadata, and does not guarantee that something is actually listening on those ports (e.g., the nginx image has both 443 and 80 as expose, but by default only listens on port 80.

Being explicit is more work, but makes sure that you know what ports will be published, and keeps you in control whether or not a port should be published. Publishing a port makes it publicly accessible and in many situations (e.g. mysql port 3306) that may not be desirable.

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.

Upgrade to 20.10 fails to release ports published to IPv6 literal addresses

6 participants