|
@@ -611,10 +611,10 @@ func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string
|
|
return errors.New("No such container: " + cmd.Arg(0))
|
|
return errors.New("No such container: " + cmd.Arg(0))
|
|
}
|
|
}
|
|
|
|
|
|
-func (srv *Server) CreateContainer(img *image.Image, tty bool, openStdin bool, comment string, cmd string, args ...string) (*docker.Container, error) {
|
|
|
|
|
|
+func (srv *Server) CreateContainer(img *image.Image, user string, tty bool, openStdin bool, comment string, cmd string, args ...string) (*docker.Container, error) {
|
|
id := future.RandomId()[:8]
|
|
id := future.RandomId()[:8]
|
|
container, err := srv.containers.Create(id, cmd, args, img.Layers,
|
|
container, err := srv.containers.Create(id, cmd, args, img.Layers,
|
|
- &docker.Config{Hostname: id, Tty: tty, OpenStdin: openStdin})
|
|
|
|
|
|
+ &docker.Config{Hostname: id, User: user, Tty: tty, OpenStdin: openStdin})
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
@@ -680,6 +680,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
|
fl_attach := cmd.Bool("a", false, "Attach stdin and stdout")
|
|
fl_attach := cmd.Bool("a", false, "Attach stdin and stdout")
|
|
fl_stdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
|
|
fl_stdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
|
|
fl_tty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
|
fl_tty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
|
|
|
+ fl_user := cmd.String("u", "0", "Username or UID")
|
|
fl_comment := cmd.String("c", "", "Comment")
|
|
fl_comment := cmd.String("c", "", "Comment")
|
|
if err := cmd.Parse(args); err != nil {
|
|
if err := cmd.Parse(args); err != nil {
|
|
return nil
|
|
return nil
|
|
@@ -706,7 +707,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
|
return errors.New("No such image: " + name)
|
|
return errors.New("No such image: " + name)
|
|
}
|
|
}
|
|
// Create new container
|
|
// Create new container
|
|
- container, err := srv.CreateContainer(img, *fl_tty, *fl_stdin, *fl_comment, cmdline[0], cmdline[1:]...)
|
|
|
|
|
|
+ container, err := srv.CreateContainer(img, *fl_user, *fl_tty, *fl_stdin, *fl_comment, cmdline[0], cmdline[1:]...)
|
|
if err != nil {
|
|
if err != nil {
|
|
return errors.New("Error creating container: " + err.Error())
|
|
return errors.New("Error creating container: " + err.Error())
|
|
}
|
|
}
|