Closed srcshelton closed 4 years ago
I remember that this change was deliberate, and relates specifically to the --net=host
case (we don't want to set a different hostname than the host if we're sharing network). I think we have two bugs here:
--hostname
is not conflicting with --net=host
/etc/hosts
insteadI 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 /etc/hosts
if the command-line arguments so request feels like a genuinely useful feature...
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.
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!
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