Have docker use the task environment in the context
This commit is contained in:
parent
442e6dbfb8
commit
ec9c375c1c
|
@ -186,13 +186,9 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
|
||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create environment variables.
|
// Set environment variables.
|
||||||
taskEnv, err := GetTaskEnv(ctx.AllocDir, d.node, task)
|
d.taskEnv.SetAllocDir(filepath.Join("/", allocdir.SharedAllocName))
|
||||||
if err != nil {
|
d.taskEnv.SetTaskLocalDir(filepath.Join("/", allocdir.TaskLocal))
|
||||||
return c, err
|
|
||||||
}
|
|
||||||
taskEnv.SetAllocDir(filepath.Join("/", allocdir.SharedAllocName))
|
|
||||||
taskEnv.SetTaskLocalDir(filepath.Join("/", allocdir.TaskLocal))
|
|
||||||
|
|
||||||
config := &docker.Config{
|
config := &docker.Config{
|
||||||
Image: driverConfig.ImageName,
|
Image: driverConfig.ImageName,
|
||||||
|
@ -352,14 +348,14 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
|
||||||
// the 0.2 ports world view. Docker seems to be the only place where
|
// the 0.2 ports world view. Docker seems to be the only place where
|
||||||
// this is actually needed, but this is kinda hacky.
|
// this is actually needed, but this is kinda hacky.
|
||||||
if len(driverConfig.PortMap) > 0 {
|
if len(driverConfig.PortMap) > 0 {
|
||||||
taskEnv.SetPorts(network.MapLabelToValues(driverConfig.PortMap))
|
d.taskEnv.SetPorts(network.MapLabelToValues(driverConfig.PortMap))
|
||||||
}
|
}
|
||||||
hostConfig.PortBindings = publishedPorts
|
hostConfig.PortBindings = publishedPorts
|
||||||
config.ExposedPorts = exposedPorts
|
config.ExposedPorts = exposedPorts
|
||||||
}
|
}
|
||||||
|
|
||||||
taskEnv.Build()
|
d.taskEnv.Build()
|
||||||
parsedArgs := taskEnv.ParseAndReplace(driverConfig.Args)
|
parsedArgs := d.taskEnv.ParseAndReplace(driverConfig.Args)
|
||||||
|
|
||||||
// If the user specified a custom command to run as their entrypoint, we'll
|
// If the user specified a custom command to run as their entrypoint, we'll
|
||||||
// inject it here.
|
// inject it here.
|
||||||
|
@ -379,7 +375,7 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
|
||||||
d.logger.Printf("[DEBUG] driver.docker: applied labels on the container: %+v", config.Labels)
|
d.logger.Printf("[DEBUG] driver.docker: applied labels on the container: %+v", config.Labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Env = taskEnv.EnvList()
|
config.Env = d.taskEnv.EnvList()
|
||||||
|
|
||||||
containerName := fmt.Sprintf("%s-%s", task.Name, ctx.AllocID)
|
containerName := fmt.Sprintf("%s-%s", task.Name, ctx.AllocID)
|
||||||
d.logger.Printf("[DEBUG] driver.docker: setting container name to: %s", containerName)
|
d.logger.Printf("[DEBUG] driver.docker: setting container name to: %s", containerName)
|
||||||
|
|
Loading…
Reference in New Issue