From c5304c3e6ab6ab5413183d6acf55995038b3999c Mon Sep 17 00:00:00 2001 From: Carlos Diaz-Padron Date: Mon, 16 Nov 2015 22:44:44 -0800 Subject: [PATCH 1/2] Add hostname parameter to Docker driver --- client/driver/docker.go | 4 +++- website/source/docs/drivers/docker.html.md | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index f2d25f9ba9f7..df02ff87979c 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -43,6 +43,7 @@ type DockerDriverConfig struct { Privileged bool `mapstructure:"privileged"` // Flag to run the container in priviledged mode DNS string `mapstructure:"dns_server"` // DNS Server for containers SearchDomains string `mapstructure:"search_domains"` // DNS Search domains for containers + Hostname string `mapstructure:"hostname"` // Hostname for containers } func (c *DockerDriverConfig) Validate() error { @@ -167,7 +168,8 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri env.SetTaskLocalDir(filepath.Join("/", allocdir.TaskLocal)) config := &docker.Config{ - Image: driverConfig.ImageName, + Image: driverConfig.ImageName, + Hostname: driverConfig.Hostname, } hostConfig := &docker.HostConfig{ diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index dfa4c85a5710..13ebf55affb4 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -42,6 +42,8 @@ The `docker` driver supports the following configuration in the job specificatio * `search-domains` - (optional) A comma separated list of DNS search domains for the container to use. + +* `hostname` - (optional) The hostname to assign to the container. **Authentication** Registry authentication can be set per task with the following authentication From c4ab2fa296122bbbf548497a8eefa42d9867e881 Mon Sep 17 00:00:00 2001 From: Carlos Diaz-Padron Date: Mon, 16 Nov 2015 23:14:28 -0800 Subject: [PATCH 2/2] Add note to Docker hostname to explain hostname duplication --- website/source/docs/drivers/docker.html.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index 13ebf55affb4..623cdd6b4aee 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -43,7 +43,9 @@ The `docker` driver supports the following configuration in the job specificatio * `search-domains` - (optional) A comma separated list of DNS search domains for the container to use. -* `hostname` - (optional) The hostname to assign to the container. +* `hostname` - (optional) The hostname to assign to the container. When launching more + than one of a task (using `count`) with this option set, every container the task + starts will have the same hostname. **Authentication** Registry authentication can be set per task with the following authentication