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", Name: "readonly",
Usage: "set the containers filesystem as 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 { Action: func(context *cli.Context) error {
var ( var (

View File

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