-
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
Podman 2.2.1 adds an additional 127.0.1.1 to /etc/hosts breaking services binding to hostname when --net=host is specified #10319
Comments
According to the code comment this is done for docker compat. podman/libpod/container_internal_linux.go Lines 1820 to 1827 in b64e20a
However I was unable to reproduce this behaviour with docker 20.10, should we just drop this @mheon? |
Hm. I see it on Docker 19.03 with |
I installed |
I went down the rabbit hole of what's going on here, and tracked down #8054 as the original issue we added this for. It looks like the request was not Docker-compatibility related - we just had a request to ensure The Docker 19.04 vs 20.10 difference is very curious, though. Would have thought this amounted to a breaking change, if they did change it. |
Interesting, they just use /etc/hosts and /etc/resolv.conf unchanged, see: https://github.com/moby/moby/blob/97303df92191878fabe4939da30ad056f7e941ea/daemon/container_operations_unix.go#L391-L399 |
Damn, entirely correct - my test VM does have a OK, that seems entirely reasonable, though IMO we should probably continue to do copies, instead of directly mounting in the host versions. Also, to ensure #8054 remains solved, I think we may want to add an entry for the current hostname if it does not exist. |
I could understand if you add something when the |
Is |
Until this is fixed, yes, that sounds like a good option. |
It's acceptable. I was not aware of the |
A friendly reminder that this issue had no activity for 30 days. |
Oops, looks like this got forgotten. I'll take it. |
Can someone confirm if this issue is fixed? if yes, which version of podman it is incorporated in. |
To match Docker's behavior, in the `--net=host` case, we need to use the host's `/etc/hosts` file, unmodified (without adding an entry for the container). We will still respect hosts from `--add-host` but will not make any automatic changes. Fortuntely, this is strictly a matter of removal and refactoring as we already base our `/etc/hosts` on the host's version - just need to remove the code that added entries when net=host was set. Fixes containers#10319 Signed-off-by: Matthew Heon <[email protected]>
To match Docker's behavior, in the `--net=host` case, we need to use the host's `/etc/hosts` file, unmodified (without adding an entry for the container). We will still respect hosts from `--add-host` but will not make any automatic changes. Fortuntely, this is strictly a matter of removal and refactoring as we already base our `/etc/hosts` on the host's version - just need to remove the code that added entries when net=host was set. Fixes containers#10319 Signed-off-by: Matthew Heon <[email protected]>
Can we reopen this @mheon? It looks like the issue is solved incorrectly:
My podman is the latest container build: 94886d4 and it contains your commit. I have a python application incorrectly detecting its primary IP as 127.0.1.1 instead of 10.244.6.78. As far as I understand, this line shouldn't be present at all. I should also note that I have an interface in the container cni-podman0 that isn't present in podman. |
@mattymo Did you created a new container? I do not know if this works for already existing ones. |
@Luap99 yes new container. I would agree that existing containers would not be affected since container set up only happens once. |
@mattymo Can you share the commands you used to create the container. |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When using
--net=host
and additional entry in/etc/hosts
is created where the hostname is bound to127.0.1.1
This has started to happen for Podman 2.2.1 on RHEL 8.3.1.
Steps to reproduce the issue:
Describe the results you received:
Content of
/etc/hosts
:Describe the results you expected:
Content of
/etc/hosts
:This is what we get on RHEL 8.3.0 with podman-2.0.5-5.module+el8.3.0+8221+97165c3f.x86_64.
Additional information you deem important (e.g. issue happens only occasionally):
N/A
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)
No, I have been using the podman that comes with RHEL 8. Yes, I have checked the troubleshooting guide.
Additional environment details (AWS, VirtualBox, physical, etc.):
Physical machine
The text was updated successfully, but these errors were encountered: