Skip to content

Commit 81a486c

Browse files
fix(runImage): use current Uid and Gid to avoid permission issues
Closes #3
1 parent 25cfda4 commit 81a486c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

soos.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log"
1010
"os"
1111
"os/exec"
12+
"os/user"
1213
"path/filepath"
1314
)
1415

@@ -134,12 +135,17 @@ func runImage(imageNameWithTag string) {
134135

135136
args := []string{"run"}
136137

138+
user, userErr := user.Current()
139+
if userErr != nil {
140+
log.Fatal(userErr)
141+
}
142+
137143
if len(getConfig().ExposePorts) != 0 {
138144
exposePortsArg := "-p" + getConfig().ExposePorts[0]
139-
args = append([]string{"run", "--rm", exposePortsArg, "-v", cwd() + ":/build/app", imageNameWithTag}, os.Args[1:]...)
145+
args = append([]string{"run", "--rm", "-u", user.Uid + ":" + user.Gid, exposePortsArg, "-v", cwd() + ":/build/app", imageNameWithTag}, os.Args[1:]...)
140146
} else {
141147

142-
args = append([]string{"run", "--rm", "-v", cwd() + ":/build/app", imageNameWithTag}, os.Args[1:]...)
148+
args = append([]string{"run", "--rm", "-u", user.Uid + ":" + user.Gid, "-v", cwd() + ":/build/app", imageNameWithTag}, os.Args[1:]...)
143149
}
144150

145151
cmd := exec.Command("docker", args...)

0 commit comments

Comments
 (0)