summaryrefslogtreecommitdiff
path: root/libpod/container_internal_linux.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-09-16 12:37:06 +0200
committerPaul Holzinger <pholzing@redhat.com>2021-09-16 18:19:15 +0200
commitf1ee234252768921313ddbbdbb7184585800bdbb (patch)
tree157ced3a14d7ef97f1ab059dc033d83c556cf0a5 /libpod/container_internal_linux.go
parent9119a578e782b92bd344f093f5491c318bc20d69 (diff)
downloadpodman-f1ee234252768921313ddbbdbb7184585800bdbb.tar.gz
podman-f1ee234252768921313ddbbdbb7184585800bdbb.tar.bz2
podman-f1ee234252768921313ddbbdbb7184585800bdbb.zip
Only add 127.0.0.1 entry to /etc/hosts with --net=none
The check for net=none was wrong. It just assumed when we do not create the netns but have one set that we use the none mode. This however also applies to a container which joins the pod netns. To correctly check for the none mode use `config.NetMode.IsNone()`. Fixes #11596 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r--libpod/container_internal_linux.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 0557b30d0..6ebbfd1f3 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -2033,15 +2033,16 @@ func (c *Container) getHosts() string {
// Do we have a network namespace?
netNone := false
- for _, ns := range c.config.Spec.Linux.Namespaces {
- if ns.Type == spec.NetworkNamespace {
- if ns.Path == "" && !c.config.CreateNetNS {
- netNone = true
+ if c.config.NetNsCtr == "" && !c.config.CreateNetNS {
+ for _, ns := range c.config.Spec.Linux.Namespaces {
+ if ns.Type == spec.NetworkNamespace {
+ if ns.Path == "" {
+ netNone = true
+ }
+ break
}
- break
}
}
-
// If we are net=none (have a network namespace, but not connected to
// anything) add the container's name and hostname to localhost.
if netNone {