Merge pull request #857 from crosbymichael/host

Add --net-host for testing host networking
This commit is contained in:
Kenfe-Mickaël Laventure 2017-05-15 15:03:07 -07:00 committed by GitHub
commit 615f748e77
2 changed files with 12 additions and 5 deletions

View File

@ -51,6 +51,10 @@ var runCommand = cli.Command{
Name: "readonly",
Usage: "set the containers filesystem as readonly",
},
cli.BoolFlag{
Name: "net-host",
Usage: "enable host networking for the container",
},
},
Action: func(context *cli.Context) error {
var (

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) {