From c3d20e78174e702f64c75cad7fb596545873f1f2 Mon Sep 17 00:00:00 2001 From: Ma Shimiao Date: Fri, 8 Sep 2017 09:30:07 +0800 Subject: [PATCH] Fixes #1585 config.Namespaces is empty when accessed Signed-off-by: Ma Shimiao --- libcontainer/specconv/spec_linux.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index 6d399089..ee3bd682 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -184,13 +184,6 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) { } exists := false - 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)) } @@ -221,6 +214,13 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) { } config.Namespaces.Add(t, ns.Path) } + if config.Namespaces.Contains(configs.NEWNET) { + config.Networks = []*configs.Network{ + { + Type: "loopback", + }, + } + } config.MaskPaths = spec.Linux.MaskedPaths config.ReadonlyPaths = spec.Linux.ReadonlyPaths config.MountLabel = spec.Linux.MountLabel