From b14412ec3623d1c892bcb0e43ab48db3d85b4195 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 27 Jul 2015 16:36:28 -0700 Subject: [PATCH] Only add network info if NEWNET is set Only add the localhost interface information to the config if the NEWNET flag is passed on the namespaces. Signed-off-by: Michael Crosby --- spec.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec.go b/spec.go index ee228d61..a70e8581 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)) }