Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hostname parameter to Docker driver #426

Merged
merged 2 commits into from
Nov 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down
4 changes: 4 additions & 0 deletions website/source/docs/drivers/docker.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ 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. 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
Expand Down