Skip to content

Commit

Permalink
feat: create container with current uid,gid (#119)
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <[email protected]>
  • Loading branch information
verbotenj authored Mar 17, 2024
1 parent 6c779af commit e74a633
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkgmgr/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"io"
"log/slog"
"os"
"sort"
"strings"

Expand Down Expand Up @@ -171,6 +172,11 @@ func (d *DockerService) Create() error {
if err != nil {
return err
}
// Set the desired user ID and group ID
userID := os.Getuid()
groupID := os.Getgid()
userAndGroup := fmt.Sprintf("%d:%d", userID, groupID)
// Create container
d.logger.Debug(fmt.Sprintf("creating container %s", d.ContainerName))
resp, err := client.ContainerCreate(
context.Background(),
Expand All @@ -180,6 +186,7 @@ func (d *DockerService) Create() error {
Entrypoint: d.Command,
Cmd: d.Args,
Env: tmpEnv[:],
User: userAndGroup,
},
&container.HostConfig{
RestartPolicy: container.RestartPolicy{
Expand Down

0 comments on commit e74a633

Please sign in to comment.