diff --git a/spec.go b/spec.go index ee228d616c6..a70e8581564 100644 --- a/spec.go +++ b/spec.go @@ -191,11 +191,6 @@ func createLibcontainerConfig(spec *specs.LinuxSpec) (*configs.Config, error) { Readonlyfs: spec.Root.Readonly, Hostname: spec.Hostname, Privatefs: true, - Networks: []*configs.Network{ - { - Type: "loopback", - }, - }, } for _, ns := range spec.Linux.Namespaces { t, exists := namespaceMapping[ns.Type] @@ -204,6 +199,13 @@ func createLibcontainerConfig(spec *specs.LinuxSpec) (*configs.Config, error) { } config.Namespaces.Add(t, ns.Path) } + if config.Namespaces.Contains(configs.NEWNET) { + config.Networks = []*configs.Network{ + { + Type: "loopback", + }, + } + } for _, m := range spec.Mounts { config.Mounts = append(config.Mounts, createLibcontainerMount(cwd, m)) }