diff --git a/drivers/docker/driver_test.go b/drivers/docker/driver_test.go index aa1cbb16c..ebcc80ea2 100644 --- a/drivers/docker/driver_test.go +++ b/drivers/docker/driver_test.go @@ -1009,6 +1009,23 @@ func TestDockerDriver_CreateContainerConfig(t *testing.T) { require.Equal(t, containerName, c.Name) } +func TestDockerDriver_CreateContainerConfig_User(t *testing.T) { + t.Parallel() + + task, cfg, _ := dockerTask(t) + task.User = "random-user-1" + + require.NoError(t, task.EncodeConcreteDriverConfig(cfg)) + + dh := dockerDriverHarness(t, nil) + driver := dh.Impl().(*Driver) + + c, err := driver.createContainerConfig(task, cfg, "org/repo:0.1") + require.NoError(t, err) + + require.Equal(t, task.User, c.Config.User) +} + func TestDockerDriver_CreateContainerConfig_Labels(t *testing.T) { t.Parallel() diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index f382b6f46..6879ea744 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -413,6 +413,8 @@ The `docker` driver supports the following configuration in the job spec. Only * `pids_limit` - (Optional) An integer value that specifies the pid limit for the container. Defaults to unlimited. +Additionally, docker driver supports customization of the container user through task [`user` option](/docs/job-specification/task.html#user). + ### Container Name Nomad creates a container after pulling an image. Containers are named