diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-22 14:26:03 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-24 10:12:33 +0200 |
commit | bd5e113b713347954b8113552019a24ccff68eef (patch) | |
tree | 78cb92d36e8b8b6d7511b686f18feefbaf71596a /libpod/container_internal_linux.go | |
parent | 5787f88042a891b877d6974d7ab9eb0b9889bd2d (diff) | |
download | podman-bd5e113b713347954b8113552019a24ccff68eef.tar.gz podman-bd5e113b713347954b8113552019a24ccff68eef.tar.bz2 podman-bd5e113b713347954b8113552019a24ccff68eef.zip |
rootless: add an entry to /etc/hosts when using slirp4netns
Closes: https://github.com/containers/libpod/issues/3405
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 60633e58c..50a2e2d44 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1069,6 +1069,10 @@ 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()) + } 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()) |