-
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
Ensure that hostname is added to hosts with net=host #8067
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mheon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
seem docker don't have this?
|
Docker is unconditionally forcing the entry in |
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]>
New changes: we now respect |
code LGTM |
Shouldn't --net=host and --hostname conflict? |
@rhatdan I don't think we are changing the host, since the container does have a UTS namespace in this case - it's just missing the net namespace. |
Ah OK, I guess they should conflict with the --uts=host, but no one ever does this. |
/lgtm |
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.Fixes #8054