diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-06 07:04:18 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-07 08:39:44 -0400 |
commit | 3ae47f7d2b9328ff47dc5702d834ae9ee296a27b (patch) | |
tree | 3818c5febd0457d5cec8cc5f09b8b34179239c7e /libpod/container_internal_linux.go | |
parent | a7500e54a4646c7db477349e2530ac13df77b8fa (diff) | |
download | podman-3ae47f7d2b9328ff47dc5702d834ae9ee296a27b.tar.gz podman-3ae47f7d2b9328ff47dc5702d834ae9ee296a27b.tar.bz2 podman-3ae47f7d2b9328ff47dc5702d834ae9ee296a27b.zip |
Populate /etc/hosts file when run in a user namespace
We do not populate the hostname field with the IP Address
when running within a user namespace.
Fixes https://github.com/containers/podman/issues/7490
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 894982973..41cc80789 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1543,10 +1543,7 @@ func (c *Container) getHosts() string { // When using slirp4netns, the interface gets a static IP hosts += fmt.Sprintf("# used by slirp4netns\n%s\t%s %s\n", "10.0.2.100", c.Hostname(), c.Config().Name) } - if len(c.state.NetworkStatus) > 0 && len(c.state.NetworkStatus[0].IPs) > 0 { - ipAddress := strings.Split(c.state.NetworkStatus[0].IPs[0].Address.String(), "/")[0] - hosts += fmt.Sprintf("%s\t%s %s\n", ipAddress, c.Hostname(), c.Config().Name) - } + hosts += c.cniHosts() return hosts } |