Add --net-host for testing host networking

Add `--net-host` to `ctr run` to test containers running in host
networking.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-05-15 13:41:57 -07:00
parent 7b2bf52f62
commit ac98ef7439
2 changed files with 12 additions and 5 deletions

View File

@@ -92,7 +92,7 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) (*specs.
if cwd == "" {
cwd = "/"
}
return &specs.Spec{
s := &specs.Spec{
Version: specs.Version,
Platform: specs.Platform{
OS: runtime.GOOS,
@@ -211,12 +211,15 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) (*specs.
{
Type: "mount",
},
{
Type: "network",
},
},
},
}, nil
}
if !context.Bool("net-host") {
s.Linux.Namespaces = append(s.Linux.Namespaces, specs.LinuxNamespace{
Type: "network",
})
}
return s, nil
}
func customSpec(configPath string, rootfs string) (*specs.Spec, error) {