From 9067a5ca11b3b25fcfcd5beafbd4a6a4bf75f7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Guid=C3=A9e?= Date: Thu, 14 Sep 2023 23:38:34 -0400 Subject: [PATCH] Run containers with the same UID/GID as the user that is running vertex --- adapter/runner_docker.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/adapter/runner_docker.go b/adapter/runner_docker.go index b80a5555..c05fd006 100644 --- a/adapter/runner_docker.go +++ b/adapter/runner_docker.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "io" + "os/user" "path" "path/filepath" "strings" @@ -84,6 +85,14 @@ func (a RunnerDockerAdapter) Start(instance *types.Instance, onLog func(msg stri vlog.String("container_name", containerName), ) + userOption := "" + currentUser, err := user.Current() + if err != nil { + log.Error(err) + } else { + userOption = currentUser.Uid + ":" + currentUser.Gid + } + options := createContainerOptions{ imageName: imageName, containerName: containerName, @@ -91,6 +100,7 @@ func (a RunnerDockerAdapter) Start(instance *types.Instance, onLog func(msg stri portBindings: nat.PortMap{}, binds: []string{}, env: []string{}, + user: userOption, capAdd: []string{}, } @@ -365,6 +375,7 @@ type createContainerOptions struct { portBindings nat.PortMap binds []string env []string + user string capAdd []string sysctls map[string]string } @@ -377,6 +388,7 @@ func (a RunnerDockerAdapter) createContainer(options createContainerOptions) (st Tty: true, AttachStdout: true, AttachStderr: true, + User: options.user, } hostConfig := container.HostConfig{