aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-03-25 12:12:18 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-03-27 10:12:18 -0400
commit236300d02832b1c131e5d70f3510e5169857b69b (patch)
tree627a606040676ff90771f7dff5a5a426c3015c06
parent16a7c7ff82e53bb29d03d816ffa53ae4ae29e86f (diff)
downloadpodman-236300d02832b1c131e5d70f3510e5169857b69b.tar.gz
podman-236300d02832b1c131e5d70f3510e5169857b69b.tar.bz2
podman-236300d02832b1c131e5d70f3510e5169857b69b.zip
Add --no-hosts flag to disable management of /etc/hosts
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r--cmd/podman/common.go4
-rw-r--r--cmd/podman/shared/create.go7
-rw-r--r--pkg/spec/createconfig.go6
3 files changed, 16 insertions, 1 deletions
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
@@ -389,6 +389,10 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"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,
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go
index fba69d1ba..15719beab 100644
--- a/pkg/spec/createconfig.go
+++ b/pkg/spec/createconfig.go
@@ -88,6 +88,7 @@ type CreateConfig struct {
ExposedPorts map[nat.Port]struct{}
GroupAdd []string // group-add
HealthCheck *manifest.Schema2HealthConfig
+ NoHosts bool
HostAdd []string //add-host
Hostname string //hostname
Image string
@@ -514,7 +515,10 @@ func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime, pod *l
if len(c.DNSOpt) > 0 {
options = append(options, libpod.WithDNSOption(c.DNSOpt))
}
- if len(c.HostAdd) > 0 {
+ if c.NoHosts {
+ options = append(options, libpod.WithNoCreateHosts())
+ }
+ if len(c.HostAdd) > 0 && !c.NoHosts {
options = append(options, libpod.WithHosts(c.HostAdd))
}
logPath := getLoggingPath(c.LogDriverOpt)