-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[5.3.1] Once again unable to connect to host from container via host.containers.internal #24970
Comments
Forgot to mention the container
|
Temporarily moved back to docker, where connectivity works fine using I think it uses slirp4netns instead, maybe that's why - no idea. |
Is your host application listening on localhost or 0.0.0.0? |
If 5.3.0 worked but 5.3.1 doesn't then this has most likely nothing to do with podman, the changes in there should have nothing to with any of this. The only relevant change in that code would be a39a749 but that only fixes a nil deref so that cannot cause such a change |
Not sure yet, this is a spring boot app and I can't find the default value: I guess I'll have to try myself: if I get a reply from my LAN address (e.g. 192.168.1.90:8080) then it's listening on 0.0.0.0, right? Otherwise only on localhost? |
Ok I guess I just confirmed that by default spring boot's web server (Tomcat, IIRC) binds to 0.0.0.0, because I was able to get responses either from localhost:8080 or 192.168.1.90:8080, which is the IP assigned to my wifi interface. |
You can get the listing address via I just tested it again here and it works fine for me. Can you check your processes for the pasta command line that was used ( |
Well I really have no idea how or why, but now it works. I have installed docker and docker-compose packages for my distro (which bring a bunch of deps, including Then I uninstalled everything again, leaving only podman and podman-compose (which is the situation I was in when opening this bug), reverted my app to use I'm honestly clueless. I'm almost tempted to rollback my OS to the previous state, although that would only apply to my root partition - so if this got somehow fixed by something left behind in my ~ by those docker/docker-compose installs, it becomes impossible to pinpoint what made this work. But TBH I'm just happy I can move on - sorry for the time spent on this. |
It happened again - I will check the pasta command used. I'll allow myself to use this comment to take some notes :D When it's working:
Now I have to wait for things to stop working again |
Oh if you host ip changes that might make a difference. |
It took me a bit, so I guess we should document
Right, that's another use case we didn't think about (and probably the only reasonable "fix" for this). For context: https://pad.passt.top/p/PastaWithoutNetworkConnectivity (section 2, even if it's unrelated to this specific issue). |
I don't have a reproducer at the moment, "hopefully" next week it will stop working again Wondering if this should be reopened, or if you want to wait for my feedback Thanks |
Well, I guess you should simply keep an eye on address changes on the host. Most likely, like @Luap99 suggested, things are breaking once the host address that pasta initially picked changes. Let's say that you start with a 192.2.0.1 address on the host. By default (without Podman configures pasta to change the destination address for outbound connections directed to 169.254.1.2 (inside the container) to 192.2.0.1 on the host. The source address doesn't change: it's 192.2.0.1 as well (both inside and outside). Now that address changes to 192.2.0.2 (because the VPN connection is re-established or because your DHCP lease is renewed with a different address), but pasta still maps packets to 192.2.0.1 as destination address, which means that they can't be used by the host. As a workaround, you can assign a fixed address to the container, as you were doing. By the way:
Docker can use both, but it's still using slirp4netns by default, see https://docs.docker.com/engine/security/rootless/#networking-errors.
If @Luap99 wants to keep this issue open as a reference for "we should change the mapping with a netlink monitor", perhaps we can reopen this. |
Ok, I just reproduced this when a change in IP address occurs due to (forced) DHCP lease expiration. To reproduce:
What would be the workaround here? Apart from a static lease, which won't always be possible (imagine a corporate environment where you don't control the router). Thanks |
Yes let's reopen this one. However I like to add this is a general problem not pasta specific. Even slirp4netns or root networking do the same thing. Podman sources one valid host ip on start and puts the as host.containers.internal. If that ip address is removed from the host it will no longer work for all network modes. In fact the pasta --map-guest-addr would be the only network mode where we can fix this actually via the netlink monitor as the inside address 169.254.1.2 stays static so no podman changes required. As such I am actually surprised that this is a new issue for you. I guess you may have multiple ips on the host and podman picks the first one which doesn't change for you. |
|
Yeah it's a bit confusing for me, too. As for docker, I guess it just happened to work because I installed it after the DHCP lease renewal, and so it was able to start clean, which is something podman couldn't cause it was already running, that's my best guess. But at this point, even on docker it's just working out of chance. Now why I never faced this issue for weeks (i.e. since 5.3 came out) and then it suddenly started happening a few days ago, is an even bigger mystery to me |
[Sorry, replacing my original answer, because I realised I'd misread the question] "Source address" is unclear here. Do you mean
@sbrivio-rh, the two code links you give don't relate to each other the way you seem to imply. The first link will parse the address we use or (1), the second is setting (3) based the information in the flow table. The flow table in turn is populated based on |
This (kind of). The destination address that's used on the host for outbound packets that are forwarded to the host. Once the host doesn't have that address anymore, mapping will fail.
Right, I missed one step, and I can't quickly find the exact code locations right now, but in any case the problem seems to be clear at this point. |
The mapping works just fine, it's just it's destination has gone away. This is essentially no different than if you accessed some random host with an untranslated address, say, This actually suggests to me that we might want yet another mapping option: one which always goes to an external address of the host. Unlike |
Actually I just realised that it might be possible to implement As @sbrivio-rh suggests you can explicitly assign the guest's address as a workaround. Note, however, that the mechanism by which this works is a bit indirect: it causes podman to set the At the passt level, another workaround would be to use Which makes me think... I'm not totally sure how this is working with slirp4netns. By default slirp maps |
Issue Description
This is what I get in my application (running in podman) when it tries to send an HTTP request to another application which is listening on host port 8080.
connection timed out after 3000 ms: host.containers.internal/169.254.1.2:8080
The URL I set on the first application to target the second is host.containers.internal:8080
Nothing is "answering" from 169.254.1.2, and yet if I curl localhost:8080 on the host, I get a reply
I have already struggled with this in the past, but applying a workaround worked fine before podman 5.3.0.
The workaround consisted in adding this snippet to
~/.config/containers/containers.conf
:With the release of 5.3.0 I had tested that removing that snippet did no harm: the thing just worked.
Now I dunno if it's a regression of 5.3.1 or something with my distro (which I also reinstalled meanwhile), but now this kind of connectivity no longer works. What's worse, even the workaround doesn't seem to work anymore.
I even tried disabling the firewall on my host. I'm using SELinux:
Any ideas?
Thanks
Steps to reproduce the issue
run a rootless podman container sending HTTP requests to host.containers.internal:8080, while having a server listening on that host port.
Describe the results you received
no connectivity
Describe the results you expected
request is routed to localhost
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
Additional environment details
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
The text was updated successfully, but these errors were encountered: