summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-05-30 14:05:49 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-30 18:40:46 +0000
commit6d90259999f8214f159583df71316b70dde5e5f1 (patch)
tree9f2138b5eb1bbf5afaf7935c644111485f8b7b71 /cmd
parent66a5bc0b72aba4baf9f6d410019228548be87dc2 (diff)
downloadpodman-6d90259999f8214f159583df71316b70dde5e5f1.tar.gz
podman-6d90259999f8214f159583df71316b70dde5e5f1.tar.bz2
podman-6d90259999f8214f159583df71316b70dde5e5f1.zip
do not allow port related args to be used with --network=container:
we cannot set additional ports on an existing container namespace, so we should not allow --network=container with publish or publish-all. Signed-off-by: baude <bbaude@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #853 Approved by: baude
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/create.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 88e717f39..a751d32aa 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -430,9 +430,12 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
if c.IsSet("network") && c.IsSet("net") {
return nil, errors.Errorf("cannot use --network and --net together. use only --network instead")
}
- networkMode := c.String("network")
- if !c.IsSet("network") && c.IsSet("net") {
- networkMode = c.String("net")
+ netMode := container.NetworkMode(c.String("network"))
+ // Make sure if network is set to container namespace, port binding is not also being asked for
+ if netMode.IsContainer() {
+ if len(c.StringSlice("publish")) > 0 || c.Bool("publish-all") {
+ return nil, errors.Errorf("cannot set port bindings on an existing container network namespace")
+ }
}
// Verify the additional hosts are in correct format
@@ -496,10 +499,10 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
LogDriverOpt: c.StringSlice("log-opt"),
MacAddress: c.String("mac-address"),
Name: c.String("name"),
- Network: networkMode,
+ Network: c.String("network"),
NetworkAlias: c.StringSlice("network-alias"),
IpcMode: ipcMode,
- NetMode: container.NetworkMode(networkMode),
+ NetMode: netMode,
UtsMode: utsMode,
PidMode: pidMode,
Pod: c.String("pod"),