aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-01-19 08:51:59 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-19 15:42:25 +0000
commita4701b56311d5d934543e2b4306b08baa844ec3f (patch)
treebcad38f7cf02a37107bfa61854a01eb58bf9868f /cmd
parent1710acd18a4630ef704c66bf0cdae76dd658776a (diff)
downloadpodman-a4701b56311d5d934543e2b4306b08baa844ec3f.tar.gz
podman-a4701b56311d5d934543e2b4306b08baa844ec3f.tar.bz2
podman-a4701b56311d5d934543e2b4306b08baa844ec3f.zip
Add --dns-search, --dns-opt, --dns-server and --add-host.
Each of these options are destructive in nature, meaning if the user adds one of them, all current ones are removed from the produced resolv.conf. * dns-server allows the user to specify dns servers. * dns-opt allows the user to specify special resolv.conf options * dns-search allows the user to specify search domains The add-host option is not destructive and truly just adds the host to /etc/hosts. Signed-off-by: baude <bbaude@redhat.com> Closes: #231 Approved by: mheon
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/create.go14
-rw-r--r--cmd/podman/spec.go13
2 files changed, 27 insertions, 0 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 262be129c..55425638f 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -83,6 +83,7 @@ type createConfig struct {
Env map[string]string //env
ExposedPorts map[nat.Port]struct{}
GroupAdd []uint32 // group-add
+ HostAdd []string //add-host
Hostname string //hostname
Image string
ImageID string
@@ -560,6 +561,18 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
networkMode = c.String("net")
}
+ // Verify the additional hosts are in correct format
+ for _, host := range c.StringSlice("add-host") {
+ if _, err := validateExtraHost(host); err != nil {
+ return nil, err
+ }
+ }
+
+ // Check for . and dns-search domains
+ if libpod.StringInSlice(".", c.StringSlice("dns-search")) && len(c.StringSlice("dns-search")) > 1 {
+ return nil, errors.Errorf("cannot pass additional search domains when also specifying '.'")
+ }
+
config := &createConfig{
Runtime: runtime,
CapAdd: c.StringSlice("cap-add"),
@@ -576,6 +589,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
ExposedPorts: ports,
GroupAdd: groupAdd,
Hostname: c.String("hostname"),
+ HostAdd: c.StringSlice("add-host"),
Image: imageName,
ImageID: imageID,
Interactive: c.Bool("interactive"),
diff --git a/cmd/podman/spec.go b/cmd/podman/spec.go
index 59ea5685a..152d1740c 100644
--- a/cmd/podman/spec.go
+++ b/cmd/podman/spec.go
@@ -584,6 +584,19 @@ func (c *createConfig) GetContainerCreateOptions() ([]libpod.CtrCreateOption, er
options = append(options, libpod.WithStopSignal(c.StopSignal))
options = append(options, libpod.WithStopTimeout(c.StopTimeout))
+ if len(c.DNSSearch) > 0 {
+ options = append(options, libpod.WithDNSSearch(c.DNSSearch))
+ }
+ if len(c.DNSServers) > 0 {
+ options = append(options, libpod.WithDNS(c.DNSServers))
+ }
+ if len(c.DNSOpt) > 0 {
+ options = append(options, libpod.WithDNSOption(c.DNSOpt))
+ }
+ if len(c.HostAdd) > 0 {
+ options = append(options, libpod.WithHosts(c.HostAdd))
+ }
+
return options, nil
}