added dnsoptions to the docker driver
This commit is contained in:
parent
46365ef22f
commit
804fc0d06f
|
@ -153,6 +153,7 @@ type DockerDriverConfig struct {
|
|||
Privileged bool `mapstructure:"privileged"` // Flag to run the container in privileged mode
|
||||
DNSServers []string `mapstructure:"dns_servers"` // DNS Server for containers
|
||||
DNSSearchDomains []string `mapstructure:"dns_search_domains"` // DNS Search domains for containers
|
||||
DNSOptions []string `mapstructure:"dns_options"` // DNS Options
|
||||
ExtraHosts []string `mapstructure:"extra_hosts"` // Add host to /etc/hosts (host:IP)
|
||||
Hostname string `mapstructure:"hostname"` // Hostname for containers
|
||||
LabelsRaw []map[string]string `mapstructure:"labels"` //
|
||||
|
@ -188,7 +189,7 @@ func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnv) (*DockerDriverC
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Interpolate everything that is a string
|
||||
// Interpolate everthing that is a string
|
||||
dconf.ImageName = env.ReplaceEnv(dconf.ImageName)
|
||||
dconf.Command = env.ReplaceEnv(dconf.Command)
|
||||
dconf.IpcMode = env.ReplaceEnv(dconf.IpcMode)
|
||||
|
@ -205,6 +206,7 @@ func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnv) (*DockerDriverC
|
|||
dconf.VolumeDriver = env.ReplaceEnv(dconf.VolumeDriver)
|
||||
dconf.DNSServers = env.ParseAndReplace(dconf.DNSServers)
|
||||
dconf.DNSSearchDomains = env.ParseAndReplace(dconf.DNSSearchDomains)
|
||||
dconf.DNSOptions = env.ParseAndReplace(dconf.DNSOptions)
|
||||
dconf.ExtraHosts = env.ParseAndReplace(dconf.ExtraHosts)
|
||||
dconf.MacAddress = env.ReplaceEnv(dconf.MacAddress)
|
||||
dconf.SecurityOpt = env.ParseAndReplace(dconf.SecurityOpt)
|
||||
|
@ -409,6 +411,9 @@ func (d *DockerDriver) Validate(config map[string]interface{}) error {
|
|||
"dns_servers": &fields.FieldSchema{
|
||||
Type: fields.TypeArray,
|
||||
},
|
||||
"dns_options": &fields.FieldSchema{
|
||||
Type: fields.TypeArray,
|
||||
},
|
||||
"dns_search_domains": &fields.FieldSchema{
|
||||
Type: fields.TypeArray,
|
||||
},
|
||||
|
@ -937,6 +942,7 @@ func (d *DockerDriver) createContainerConfig(ctx *ExecContext, task *structs.Tas
|
|||
|
||||
// set DNS search domains and extra hosts
|
||||
hostConfig.DNSSearch = driverConfig.DNSSearchDomains
|
||||
hostConfig.DNSOptions = driverConfig.DNSOptions
|
||||
hostConfig.ExtraHosts = driverConfig.ExtraHosts
|
||||
|
||||
hostConfig.IpcMode = driverConfig.IpcMode
|
||||
|
|
|
@ -861,6 +861,7 @@ func TestDockerDriver_DNS(t *testing.T) {
|
|||
task, _, _ := dockerTask()
|
||||
task.Config["dns_servers"] = []string{"8.8.8.8", "8.8.4.4"}
|
||||
task.Config["dns_search_domains"] = []string{"example.com", "example.org", "example.net"}
|
||||
task.Config["dns_options"] = []string{"ndots:1"}
|
||||
|
||||
client, handle, cleanup := dockerSetup(t, task)
|
||||
defer cleanup()
|
||||
|
@ -879,6 +880,10 @@ func TestDockerDriver_DNS(t *testing.T) {
|
|||
if !reflect.DeepEqual(task.Config["dns_search_domains"], container.HostConfig.DNSSearch) {
|
||||
t.Errorf("DNS Servers don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_search_domains"], container.HostConfig.DNSSearch)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(task.Config["dns_options"], container.HostConfig.DNSOptions) {
|
||||
t.Errorf("DNS Servers don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_options"], container.HostConfig.DNSOptions)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDockerDriver_MACAddress(t *testing.T) {
|
||||
|
|
|
@ -78,6 +78,9 @@ The `docker` driver supports the following configuration in the job spec. Only
|
|||
* `dns_search_domains` - (Optional) A list of DNS search domains for the container
|
||||
to use.
|
||||
|
||||
|
||||
* `dns_options` - (Optional) A list of DNS options for the container to use.
|
||||
|
||||
* `dns_servers` - (Optional) A list of DNS servers for the container to use
|
||||
(e.g. ["8.8.8.8", "8.8.4.4"]). Requires Docker v1.10 or greater.
|
||||
|
||||
|
|
Loading…
Reference in a new issue