Skip to content

Commit

Permalink
Merge pull request #23 from Crazybus/i_am_root
Browse files Browse the repository at this point in the history
Default to root user for all oses. Using a user that doesn't exist
  • Loading branch information
Crazybus authored Jun 3, 2018
2 parents c20c1d0 + a59e70c commit 5bf8896
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ env:
| -entrypoint _string_ | The entrypoint for running the lope command (default `/bin/sh`) |
| -instruction _value_ | Extra docker image instructions to run when building the image. Can be specified multiple times |
| -noDocker | Disables mounting the docker socket inside the container (default `false`) |
| -noRoot | Use current user instead of the root user (default `false`) |
| -noTty | Disable the --tty flag (default `false`) |
| -noMount | Disable mounting the current working directory into the image |
| -noSSH | Disable forwarding ssh agent into the container |
Expand Down
12 changes: 5 additions & 7 deletions lope.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type config struct {
image string
mount bool
os string
root bool
sourceImage string
ssh bool
instructions []string
Expand Down Expand Up @@ -217,14 +218,8 @@ func (l *lope) addVolumes() {
}

func (l *lope) addUserAndGroup() {
// This is only needed on linux since Windows and OSX don't allow a docker root user to create
// files that the current user can't manage
if l.cfg.os != "linux" {
return
}

// Only run the container as the host user and group if we are bind mounting the current directory
if !l.cfg.mount {
if l.cfg.root {
return
}

Expand Down Expand Up @@ -401,6 +396,8 @@ func main() {

addDocker := flag.Bool("addDocker", false, "Uses wget to download the docker client binary into the image")

noRoot := flag.Bool("noRoot", false, "Use current user instead of the root user")

flag.Parse()
if flag.NArg() < 2 {
fmt.Fprintf(os.Stderr, "Usage of %[1]s:\n %[1]s [options] <docker-image> <command>\n\nOptions:\n", filepath.Base(os.Args[0]))
Expand Down Expand Up @@ -440,6 +437,7 @@ func main() {
mount: mount,
os: runtime.GOOS,
paths: paths,
root: !*noRoot,
sourceImage: args[0],
ssh: !*noSSH,
tty: !*noTty,
Expand Down

0 comments on commit 5bf8896

Please sign in to comment.