mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
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
This commit is contained in:

committed by
Atomic Bot

parent
66a5bc0b72
commit
6d90259999
@ -430,9 +430,12 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
|
|||||||
if c.IsSet("network") && c.IsSet("net") {
|
if c.IsSet("network") && c.IsSet("net") {
|
||||||
return nil, errors.Errorf("cannot use --network and --net together. use only --network instead")
|
return nil, errors.Errorf("cannot use --network and --net together. use only --network instead")
|
||||||
}
|
}
|
||||||
networkMode := c.String("network")
|
netMode := container.NetworkMode(c.String("network"))
|
||||||
if !c.IsSet("network") && c.IsSet("net") {
|
// Make sure if network is set to container namespace, port binding is not also being asked for
|
||||||
networkMode = c.String("net")
|
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
|
// 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"),
|
LogDriverOpt: c.StringSlice("log-opt"),
|
||||||
MacAddress: c.String("mac-address"),
|
MacAddress: c.String("mac-address"),
|
||||||
Name: c.String("name"),
|
Name: c.String("name"),
|
||||||
Network: networkMode,
|
Network: c.String("network"),
|
||||||
NetworkAlias: c.StringSlice("network-alias"),
|
NetworkAlias: c.StringSlice("network-alias"),
|
||||||
IpcMode: ipcMode,
|
IpcMode: ipcMode,
|
||||||
NetMode: container.NetworkMode(networkMode),
|
NetMode: netMode,
|
||||||
UtsMode: utsMode,
|
UtsMode: utsMode,
|
||||||
PidMode: pidMode,
|
PidMode: pidMode,
|
||||||
Pod: c.String("pod"),
|
Pod: c.String("pod"),
|
||||||
|
Reference in New Issue
Block a user