-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Pod cannot redirect ports if IP is 0.0.0.0 #7014
Comments
Oops I just realized the same is happening when opening direct ports from containers: sudo podman run -d --name test3_traefik -p 10003:10003 traefik --log.level debug --entryPoints.test.address=:10003
sudo podman exec test3_traefik wget localhost:10003 --timeout 5 --tries 1
wget localhost:10003 --timeout 5 --tries 1
sudo podman run -d --name test4_traefik -p 0.0.0.0:10004:10004 traefik --log.level debug --entryPoints.test.address=:10004
sudo podman exec test4_traefik wget localhost:10004 --timeout 5 --tries 1
wget localhost:10004 --timeout 5 --tries 1 Results
(Remember 404 = 👍 in this test) |
I think it might be interesting for you a proof on how this works fine with docker. Just run this test: sudo docker run -d --name test5_traefik -p 10005:10005 traefik --log.level debug --entryPoints.test.address=:10005
sudo docker exec test5_traefik wget localhost:10005 --timeout 5 --tries 1
wget localhost:10005 --timeout 5 --tries 1
sudo docker run -d --name test6_traefik -p 0.0.0.0:10006:10006 traefik --log.level debug --entryPoints.test.address=:10006
sudo docker exec test6_traefik wget localhost:10006 --timeout 5 --tries 1
wget localhost:10006 --timeout 5 --tries 1 Results
(Remember 404 = 👍 in this test) |
This looks like a bug in CNI - the only different is that we're handing it a host IP of From an IPTables perspective, the two generate almost identical rules, with one key exception - destination IP for "0.0.0.0" is literally "0.0.0.0" - whereas, if it's unset, it's "0.0.0.0/0". At this point, I'm leaning towards detecting 0.0.0.0 and replacing is with "" when parsing port mappings. |
Docker and CNI have very different ideas of what 0.0.0.0 means. Docker takes it to be 0.0.0.0/0 - that is, bind to every IPv4 address on the host. CNI (and, thus, root Podman) take it to mean the literal IP 0.0.0.0. Instead, CNI interprets the empty string ("") as "bind to all IPs". We could ask CNI to change, but given this is established behavior, that's unlikely. Instead, let's just catch 0.0.0.0 and turn it into "" when we parse ports. Fixes containers#7014 Signed-off-by: Matthew Heon <[email protected]>
Another difference that I'm not sure if is true could be if adding 0.0.0.0 opens the port only on ipv4 networks. |
Docker and CNI have very different ideas of what 0.0.0.0 means. Docker takes it to be 0.0.0.0/0 - that is, bind to every IPv4 address on the host. CNI (and, thus, root Podman) take it to mean the literal IP 0.0.0.0. Instead, CNI interprets the empty string ("") as "bind to all IPs". We could ask CNI to change, but given this is established behavior, that's unlikely. Instead, let's just catch 0.0.0.0 and turn it into "" when we parse ports. Fixes containers#7014 Signed-off-by: Matthew Heon <[email protected]>
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When using a pod to redirect host ports to container ports, if the interface declared in the pod is
0.0.0.0
, it will not work. This is unexpected, because it works fine on containers.Steps to reproduce the issue:
Run this script:
Describe the results you received:
The last command (wget on host machine) works fine on test1 (returns 404 error... but that's OK for us), but fails on test2.
Describe the results you expected:
Both tests should pass equally.
Additional information you deem important (e.g. issue happens only occasionally):
I think this started happening on podman v2.
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Additional environment details (AWS, VirtualBox, physical, etc.):
GNOME Boxes amd64 VM with Ubuntu 20.04.
The text was updated successfully, but these errors were encountered: