Merge pull request #2547 from hashicorp/f-extra-hosts
Add ExtraHosts to Docker driver
This commit is contained in:
commit
718a8ccb6a
|
@ -146,6 +146,7 @@ type DockerDriverConfig struct {
|
||||||
Privileged bool `mapstructure:"privileged"` // Flag to run the container in privileged mode
|
Privileged bool `mapstructure:"privileged"` // Flag to run the container in privileged mode
|
||||||
DNSServers []string `mapstructure:"dns_servers"` // DNS Server for containers
|
DNSServers []string `mapstructure:"dns_servers"` // DNS Server for containers
|
||||||
DNSSearchDomains []string `mapstructure:"dns_search_domains"` // DNS Search domains for containers
|
DNSSearchDomains []string `mapstructure:"dns_search_domains"` // DNS Search domains for containers
|
||||||
|
ExtraHosts []string `mapstructure:"extra_hosts"` // Add host to /etc/hosts (host:IP)
|
||||||
Hostname string `mapstructure:"hostname"` // Hostname for containers
|
Hostname string `mapstructure:"hostname"` // Hostname for containers
|
||||||
LabelsRaw []map[string]string `mapstructure:"labels"` //
|
LabelsRaw []map[string]string `mapstructure:"labels"` //
|
||||||
Labels map[string]string `mapstructure:"-"` // Labels to set when the container starts up
|
Labels map[string]string `mapstructure:"-"` // Labels to set when the container starts up
|
||||||
|
@ -200,6 +201,7 @@ func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnvironment) (*Docke
|
||||||
dconf.VolumeDriver = env.ReplaceEnv(dconf.VolumeDriver)
|
dconf.VolumeDriver = env.ReplaceEnv(dconf.VolumeDriver)
|
||||||
dconf.DNSServers = env.ParseAndReplace(dconf.DNSServers)
|
dconf.DNSServers = env.ParseAndReplace(dconf.DNSServers)
|
||||||
dconf.DNSSearchDomains = env.ParseAndReplace(dconf.DNSSearchDomains)
|
dconf.DNSSearchDomains = env.ParseAndReplace(dconf.DNSSearchDomains)
|
||||||
|
dconf.ExtraHosts = env.ParseAndReplace(dconf.ExtraHosts)
|
||||||
|
|
||||||
for _, m := range dconf.LabelsRaw {
|
for _, m := range dconf.LabelsRaw {
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
|
@ -372,6 +374,9 @@ func (d *DockerDriver) Validate(config map[string]interface{}) error {
|
||||||
"dns_search_domains": &fields.FieldSchema{
|
"dns_search_domains": &fields.FieldSchema{
|
||||||
Type: fields.TypeArray,
|
Type: fields.TypeArray,
|
||||||
},
|
},
|
||||||
|
"extra_hosts": &fields.FieldSchema{
|
||||||
|
Type: fields.TypeArray,
|
||||||
|
},
|
||||||
"hostname": &fields.FieldSchema{
|
"hostname": &fields.FieldSchema{
|
||||||
Type: fields.TypeString,
|
Type: fields.TypeString,
|
||||||
},
|
},
|
||||||
|
@ -818,10 +823,9 @@ func (d *DockerDriver) createContainerConfig(ctx *ExecContext, task *structs.Tas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set DNS search domains
|
// set DNS search domains and extra hosts
|
||||||
for _, domain := range driverConfig.DNSSearchDomains {
|
hostConfig.DNSSearch = driverConfig.DNSSearchDomains
|
||||||
hostConfig.DNSSearch = append(hostConfig.DNSSearch, domain)
|
hostConfig.ExtraHosts = driverConfig.ExtraHosts
|
||||||
}
|
|
||||||
|
|
||||||
hostConfig.IpcMode = driverConfig.IpcMode
|
hostConfig.IpcMode = driverConfig.IpcMode
|
||||||
hostConfig.PidMode = driverConfig.PidMode
|
hostConfig.PidMode = driverConfig.PidMode
|
||||||
|
|
|
@ -160,6 +160,9 @@ The `docker` driver supports the following configuration in the job spec:
|
||||||
* `dns_search_domains` - (Optional) A list of DNS search domains for the container
|
* `dns_search_domains` - (Optional) A list of DNS search domains for the container
|
||||||
to use.
|
to use.
|
||||||
|
|
||||||
|
* `extra_hosts` - (Optional) A list of hosts, given as host:IP, to be added to
|
||||||
|
`/etc/hosts`.
|
||||||
|
|
||||||
* `SSL` - (Optional) If this is set to true, Nomad uses SSL to talk to the
|
* `SSL` - (Optional) If this is set to true, Nomad uses SSL to talk to the
|
||||||
repository. The default value is `true`. **Deprecated as of 0.5.3**
|
repository. The default value is `true`. **Deprecated as of 0.5.3**
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue