Skip to content

Commit

Permalink
Merge pull request #1340 from chainguard-dev/revert-1298-docker-non-z…
Browse files Browse the repository at this point in the history
…ero-uid

Revert "Use current user's ID when building via Docker"
  • Loading branch information
joshrwolf committed Jul 1, 2024
2 parents ab7c4d3 + 01fe5fe commit 5651eee
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions pkg/container/docker/docker_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"io"
"os"
"os/user"

"go.opentelemetry.io/otel"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -226,20 +225,8 @@ func (dk *docker) Run(ctx context.Context, cfg *mcontainer.Config, args ...strin
environ = append(environ, fmt.Sprintf("%s=%s", k, v))
}

// Default to the current user's UID
// Use a configured UID if it's not empty
currentUser, err := user.Current()
if err != nil {
return fmt.Errorf("failed to get current user: %w", err)
}

uid := currentUser.Uid
if cfg.RunAs != "" {
uid = cfg.RunAs
}

taskIDResp, err := dk.cli.ContainerExecCreate(ctx, cfg.PodID, container.ExecOptions{
User: uid,
User: cfg.RunAs,
Cmd: args,
WorkingDir: runnerWorkdir,
Env: environ,
Expand Down

0 comments on commit 5651eee

Please sign in to comment.