From 7021ac3ce8e5d475afab49eb3e9cacc5d693f357 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 25 Sep 2015 23:28:23 -0700 Subject: [PATCH] Add docker 'command' to docs; cleanup some comments --- client/driver/docker.go | 8 ++++---- website/source/docs/drivers/docker.html.md | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index 4ddebbd78..06f1bac96 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -193,7 +193,8 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle var dockerImage *docker.Image // We're going to check whether the image is already downloaded. If the tag - // is "latest" we have to check for a new version every time. + // is "latest" we have to check for a new version every time so we don't + // bother to check and cache the id here. We'll download first, then cache. if tag != "latest" { dockerImage, err = client.InspectImage(image) } @@ -204,7 +205,7 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle Repository: repo, Tag: tag, } - // TODO add auth configuration + // TODO add auth configuration for private repos authOptions := docker.AuthConfiguration{} err = client.PullImage(pullOptions, authOptions) if err != nil { @@ -235,6 +236,7 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle d.logger.Printf("[ERR] driver.docker: %s", err) return nil, fmt.Errorf("Failed to create container from image %s", image) } + // Sanity check if !reDockerSha.MatchString(container.ID) { return nil, fmt.Errorf("Container id not in expected format (sha256); found %s", container.ID) @@ -280,8 +282,6 @@ func (d *DockerDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, er } // Look for a running container with this ID - // docker ps does not return an exit code if there are no matching processes - // so we have to read the output and compare it to our known containerID containers, err := client.ListContainers(docker.ListContainersOptions{ Filters: map[string][]string{ "id": []string{pid.ContainerID}, diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index c7911309c..9f26654af 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -21,6 +21,8 @@ The `docker` driver supports the following configuration in the job specificatio * `image` - (Required) The Docker image to run. The image may include a tag or custom URL. By default it will be fetched from Docker Hub. +* `command` - (Optional) The command to run when starting the container. + ### Port Mapping Nomad uses port binding to expose services running in containers using the port