diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-06-21 12:23:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-21 12:23:49 +0200 |
commit | 0e4b73456d4c545136a5cfd664b6d9d819ffc498 (patch) | |
tree | 978cd016fec36dc7fdd01dad57df46070ffcc9b6 /libpod | |
parent | 4a1dd9f9a416a7098a707436e1285eaa5cfc1722 (diff) | |
parent | 5b3503c0a1bf93dc327145e8952ed5b05932dee5 (diff) | |
download | podman-0e4b73456d4c545136a5cfd664b6d9d819ffc498.tar.gz podman-0e4b73456d4c545136a5cfd664b6d9d819ffc498.tar.bz2 podman-0e4b73456d4c545136a5cfd664b6d9d819ffc498.zip |
Merge pull request #6683 from rhatdan/hostname
Add container name to the /etc/hosts within the container
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal_linux.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 12c1abf1c..5ee6726e0 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1410,13 +1410,14 @@ func (c *Container) getHosts() string { hosts += fmt.Sprintf("%s %s\n", fields[1], fields[0]) } } + if c.config.NetMode.IsSlirp4netns() { // When using slirp4netns, the interface gets a static IP - hosts += fmt.Sprintf("# used by slirp4netns\n%s\t%s\n", "10.0.2.100", c.Hostname()) + 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\n", ipAddress, c.Hostname()) + hosts += fmt.Sprintf("%s\t%s %s\n", ipAddress, c.Hostname(), c.Config().Name) } return hosts } |