-
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
hostname is (still) not added to /etc/hosts #8054
Comments
I remember that this change was deliberate, and relates specifically to the
I need to verify the correct behavior of the second one against Docker on Monday before I can be certain there, though. |
It's worth noting that in this case the container seems to get a random string of digits and alphabetic characters as hostname by default, and I'm actually trying to give the real system hostname back to the container! (Is the system hostname a thing which isn't namespaced, similarly to sysctl tunables - or can containers with host-networking legitimately have a separate hostname on the same network (whether this is registered in DNS, or known only to the container itself)?) Even if there's no safe/catch-all option available, explicitly exposing the option to inject the container hostname into |
Hostname is namespaced by the UTS namespace, so I believe it is technically possible to have a different hostname in the container despite sharing the network. This is not exactly a sane thing to do (not only are the two hostnames sharing an IP address, they're sharing the full network stack, so things can get confusing) hence the restriction here. I think we probably ought to be setting container hostname to the same hostname as the host system in this case, instead of what we seem to be doing (nothing). Will verify what's expected against Docker tomorrow. |
That'd be perfect for my use-case! |
When a container uses --net=host the default hostname is set to the host's hostname. However, we were not creating any entries in `/etc/hosts` despite having a hostname, which is incorrect. This hostname, for Docker compat, will always be the hostname of the host system, not the container, and will be assigned to IP 127.0.1.1 (not the standard localhost address). Also, when `--hostname` and `--net=host` are both passed, still use the hostname from `--hostname`, not the host's hostname (we still use the host's hostname by default in this case if the `--hostname` flag is not passed). Fixes containers#8054 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
Despite issue #1745, I'm still not seeing the container hostname injected into
/etc/hosts
- I only realised this recently on trying to launch a Java-based container, and seeing an error regarding not being able to resolve the local hostname (... which is untrue - it resolves just fine, it just doesn't existing in /etc/hosts).This happens both when
podman
is and isn't executed with a--hostname
parameter - but (and this could be key) all of this set of containers are being launched with--network=host
(and as root) - is the hostname injection logic only working when container networking is private and/or when run as a non-root user?(It doesn't appear to make a difference whether the user within the container is
root
or unprivileged)Output of
podman version
:Output of
podman info --debug
:Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?
Yes
The text was updated successfully, but these errors were encountered: