summaryrefslogtreecommitdiff
path: root/cmd/podman/create.go
diff options
context:
space:
mode:
authorQi Wang <qiwan@redhat.com>2019-07-15 13:54:12 -0400
committerQi Wang <qiwan@redhat.com>2019-07-18 09:39:31 -0400
commit3f721f8b17780931a75f9e072e4d32bf9a49e976 (patch)
treede237c123cdeb0ceaae1d494443d1dc9b8a6f97f /cmd/podman/create.go
parentadcde2383f1da517c5788516d639745f5f01d300 (diff)
downloadpodman-3f721f8b17780931a75f9e072e4d32bf9a49e976.tar.gz
podman-3f721f8b17780931a75f9e072e4d32bf9a49e976.tar.bz2
podman-3f721f8b17780931a75f9e072e4d32bf9a49e976.zip
fix --dns* and --network not set to host conflict
Close #3553 This PR makes --dns, --dns-option, --dns-search, and --network not set to host flag mutually exclusive for podman build and create. Returns conflict error if both flags are set. Signed-off-by: Qi Wang <qiwan@redhat.com>
Diffstat (limited to 'cmd/podman/create.go')
-rw-r--r--cmd/podman/create.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 262cdffe4..3c24729c5 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "strings"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/pkg/adapter"
@@ -77,6 +78,16 @@ func createInit(c *cliconfig.PodmanCommand) error {
logrus.Warn("setting security options with --privileged has no effect")
}
+ var setNet string
+ if c.IsSet("network") {
+ setNet = c.String("network")
+ } else if c.IsSet("net") {
+ setNet = c.String("net")
+ }
+ if (c.IsSet("dns") || c.IsSet("dns-opt") || c.IsSet("dns-search")) && (setNet == "none" || strings.HasPrefix(setNet, "container:")) {
+ return errors.Errorf("conflicting options: dns and the network mode.")
+ }
+
// Docker-compatibility: the "-h" flag for run/create is reserved for
// the hostname (see https://github.com/containers/libpod/issues/1367).