summaryrefslogtreecommitdiff
path: root/libpod/container_internal_linux.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-10-06 07:04:18 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-10-07 08:39:44 -0400
commit3ae47f7d2b9328ff47dc5702d834ae9ee296a27b (patch)
tree3818c5febd0457d5cec8cc5f09b8b34179239c7e /libpod/container_internal_linux.go
parenta7500e54a4646c7db477349e2530ac13df77b8fa (diff)
downloadpodman-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.go5
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
}