diff options
author | baude <bbaude@redhat.com> | 2017-12-21 12:33:10 -0600 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-12-30 10:26:14 +0000 |
commit | ef4035e208f1431745cd044adb4b789fab3a98b6 (patch) | |
tree | 355c3667f5ba5aa537133254261a8cd383c69df5 /cmd/podman/spec.go | |
parent | 7e922b103595fe64938a910fd4cd862685624391 (diff) | |
download | podman-ef4035e208f1431745cd044adb4b789fab3a98b6.tar.gz podman-ef4035e208f1431745cd044adb4b789fab3a98b6.tar.bz2 podman-ef4035e208f1431745cd044adb4b789fab3a98b6.zip |
Host networking
Allow for the user to specify network=host|bridge. If network
is not specified, the default will be bridge. While "none" is now
a valid option, it is not included in this.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #164
Approved by: rhatdan
Diffstat (limited to 'cmd/podman/spec.go')
-rw-r--r-- | cmd/podman/spec.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/cmd/podman/spec.go b/cmd/podman/spec.go index 037b18950..e000467e2 100644 --- a/cmd/podman/spec.go +++ b/cmd/podman/spec.go @@ -73,15 +73,16 @@ func addPidNS(config *createConfig, g *generate.Generator) error { func addNetNS(config *createConfig, g *generate.Generator) error { netMode := config.NetMode if netMode.IsHost() { + logrus.Debug("Using host netmode") return g.RemoveLinuxNamespace(libpod.NetNamespace) - } - if netMode.IsNone() { - return libpod.ErrNotImplemented - } - if netMode.IsBridge() { - return libpod.ErrNotImplemented - } - if netMode.IsContainer() { + } else if netMode.IsNone() { + logrus.Debug("Using none netmode") + return nil + } else if netMode.IsBridge() { + logrus.Debug("Using bridge netmode") + return nil + } else if netMode.IsContainer() { + logrus.Debug("Using container netmode") ctr, err := config.Runtime.LookupContainer(netMode.ConnectedContainer()) if err != nil { return errors.Wrapf(err, "container %q not found", netMode.ConnectedContainer()) @@ -94,6 +95,8 @@ func addNetNS(config *createConfig, g *generate.Generator) error { if err := g.AddOrReplaceLinuxNamespace(libpod.NetNamespace, nsPath); err != nil { return err } + } else { + return errors.Errorf("unknown network mode") } return nil } @@ -556,8 +559,9 @@ func (c *createConfig) GetContainerCreateOptions() ([]libpod.CtrCreateOption, er options = append(options, libpod.WithName(c.Name)) } // TODO parse ports into libpod format and include - // TODO should not happen if --net=host - options = append(options, libpod.WithNetNS([]ocicni.PortMapping{})) + if !c.NetMode.IsHost() { + options = append(options, libpod.WithNetNS([]ocicni.PortMapping{})) + } options = append(options, libpod.WithStopSignal(c.StopSignal)) options = append(options, libpod.WithStopTimeout(c.StopTimeout)) return options, nil |