From 236300d02832b1c131e5d70f3510e5169857b69b Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 25 Mar 2019 12:12:18 -0400 Subject: Add --no-hosts flag to disable management of /etc/hosts Signed-off-by: Matthew Heon --- cmd/podman/common.go | 4 ++++ cmd/podman/shared/create.go | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'cmd/podman') diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 771738302..167b3e845 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -388,6 +388,10 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "network", getDefaultNetwork(), "Connect a container to a network", ) + createFlags.Bool( + "no-hosts", false, + "Do not create /etc/hosts within the container, instead use the version from the image", + ) createFlags.Bool( "oom-kill-disable", false, "Disable OOM Killer", diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 5ce0b8865..fc55e6f17 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -357,6 +357,12 @@ func ParseCreateOpts(ctx context.Context, c *cliconfig.PodmanCommand, runtime *l return nil, errors.Errorf("--cpu-quota and --cpus cannot be set together") } + if c.Flag("no-hosts").Changed && c.Flag("add-host").Changed { + if c.Bool("no-hosts") { + return nil, errors.Errorf("--no-hosts and --add-host cannot be set together") + } + } + // EXPOSED PORTS var portBindings map[nat.Port][]nat.PortBinding if data != nil { @@ -646,6 +652,7 @@ func ParseCreateOpts(ctx context.Context, c *cliconfig.PodmanCommand, runtime *l GroupAdd: c.StringSlice("group-add"), Hostname: c.String("hostname"), HostAdd: c.StringSlice("add-host"), + NoHosts: c.Bool("no-hosts"), IDMappings: idmappings, Image: imageName, ImageID: imageID, -- cgit v1.2.3-54-g00ecf