Browse code

Server: Restored -u option (from merge)

Andrea Luzzardi authored on 2013/02/14 10:41:50
Showing 1 changed files
... ...
@@ -619,10 +619,10 @@ func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string
619 619
 	return errors.New("No such container: " + cmd.Arg(0))
620 620
 }
621 621
 
622
-func (srv *Server) CreateContainer(img *image.Image, tty bool, openStdin bool, comment string, cmd string, args ...string) (*docker.Container, error) {
622
+func (srv *Server) CreateContainer(img *image.Image, user string, tty bool, openStdin bool, comment string, cmd string, args ...string) (*docker.Container, error) {
623 623
 	id := future.RandomId()[:8]
624 624
 	container, err := srv.containers.Create(id, cmd, args, img.Layers,
625
-		&docker.Config{Hostname: id, Tty: tty, OpenStdin: openStdin})
625
+		&docker.Config{Hostname: id, User: user, Tty: tty, OpenStdin: openStdin})
626 626
 	if err != nil {
627 627
 		return nil, err
628 628
 	}
... ...
@@ -685,6 +685,7 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...stri
685 685
 
686 686
 func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
687 687
 	cmd := rcli.Subcmd(stdout, "run", "[OPTIONS] IMAGE COMMAND [ARG...]", "Run a command in a new container")
688
+	fl_user := cmd.String("u", "", "Username or UID")
688 689
 	fl_attach := cmd.Bool("a", false, "Attach stdin and stdout")
689 690
 	fl_stdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
690 691
 	fl_tty := cmd.Bool("t", false, "Allocate a pseudo-tty")
... ...
@@ -714,7 +715,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
714 714
 		return errors.New("No such image: " + name)
715 715
 	}
716 716
 	// Create new container
717
-	container, err := srv.CreateContainer(img, *fl_tty, *fl_stdin, *fl_comment, cmdline[0], cmdline[1:]...)
717
+	container, err := srv.CreateContainer(img, *fl_user, *fl_tty, *fl_stdin, *fl_comment, cmdline[0], cmdline[1:]...)
718 718
 	if err != nil {
719 719
 		return errors.New("Error creating container: " + err.Error())
720 720
 	}