diff --git a/libpod/container.go b/libpod/container.go index 68e22468063..ce29ac4e7a9 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -1459,18 +1459,20 @@ func (c *Container) NetworkMode() string { // If there is none, it's host networking. // If there is one and it has a path, it's "ns:". foundNetNS := false - for _, ns := range ctrSpec.Linux.Namespaces { - if ns.Type == spec.NetworkNamespace { - foundNetNS = true - if ns.Path != "" { - networkMode = fmt.Sprintf("ns:%s", ns.Path) - } else { - // We're making a network ns, but not - // configuring with Slirp or CNI. That - // means it's --net=none - networkMode = "none" + if ctrSpec.Linux != nil { + for _, ns := range ctrSpec.Linux.Namespaces { + if ns.Type == spec.NetworkNamespace { + foundNetNS = true + if ns.Path != "" { + networkMode = fmt.Sprintf("ns:%s", ns.Path) + } else { + // We're making a network ns, but not + // configuring with Slirp or CNI. That + // means it's --net=none + networkMode = "none" + } + break } - break } } if !foundNetNS {