summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-11-07 08:58:19 -0800
committerGitHub <noreply@github.com>2018-11-07 08:58:19 -0800
commit90662c2fa3c4069dcf34c01dd3011a20cecde6ee (patch)
tree10a0ff437ed2eb676eefefe5cde7a62aae0d2bce /libpod/container_internal.go
parent48914d67aed53ad793d86c98a6a4e96cfefe7333 (diff)
parent879f9116de8a186558fb4e7b6a259b1b8ad1aaca (diff)
downloadpodman-90662c2fa3c4069dcf34c01dd3011a20cecde6ee.tar.gz
podman-90662c2fa3c4069dcf34c01dd3011a20cecde6ee.tar.bz2
podman-90662c2fa3c4069dcf34c01dd3011a20cecde6ee.zip
Merge pull request #1751 from QiWang19/issue1745
Add hostname to /etc/hosts
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index d928c4aed..9bdf4b8fc 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1157,6 +1157,10 @@ func (c *Container) generateHosts() (string, error) {
hosts += fmt.Sprintf("%s %s\n", fields[1], fields[0])
}
}
+ 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\n", ipAddress, c.Hostname())
+ }
return c.writeStringToRundir("hosts", hosts)
}