From 3f721f8b17780931a75f9e072e4d32bf9a49e976 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Mon, 15 Jul 2019 13:54:12 -0400 Subject: 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 --- cmd/podman/create.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cmd/podman') 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). -- cgit v1.2.3-54-g00ecf