diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-10-22 11:25:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-22 11:25:27 -0400 |
commit | d340f8523c9610644c8a195d1e3e9b3a5d32c5b3 (patch) | |
tree | 613012b62e5b3d0308e43ce63a753c1bf69f63c6 /libpod | |
parent | 2cb12bbc5a832e5b69d3b52480377df716dc543b (diff) | |
parent | 0864d82cb57097e6632fd2206d4e5b42861ec6e2 (diff) | |
download | podman-d340f8523c9610644c8a195d1e3e9b3a5d32c5b3.tar.gz podman-d340f8523c9610644c8a195d1e3e9b3a5d32c5b3.tar.bz2 podman-d340f8523c9610644c8a195d1e3e9b3a5d32c5b3.zip |
Merge pull request #8101 from mheon/net_none_hostname
Add hostname to /etc/hosts for --net=none
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal_linux.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index ffb2f5b73..2efe0d086 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1550,9 +1550,13 @@ func (c *Container) getHosts() string { hosts += fmt.Sprintf("# used by slirp4netns\n%s\t%s %s\n", "10.0.2.100", c.Hostname(), c.config.Name) } else { hasNetNS := false + netNone := false for _, ns := range c.config.Spec.Linux.Namespaces { if ns.Type == spec.NetworkNamespace { hasNetNS = true + if ns.Path == "" && !c.config.CreateNetNS { + netNone = true + } break } } @@ -1564,6 +1568,9 @@ func (c *Container) getHosts() string { } hosts += fmt.Sprintf("127.0.1.1 %s\n", osHostname) } + if netNone { + hosts += fmt.Sprintf("127.0.1.1 %s\n", c.Hostname()) + } } } return hosts |