'docker run' with no argument runs a shell in the base image

This commit is contained in:
Solomon Hykes 2013-01-29 15:51:04 -08:00
parent d5be77075a
commit 29410f43a0
1 changed files with 14 additions and 4 deletions

View File

@ -597,11 +597,21 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return nil return nil
} }
if flags.NArg() < 2 { name := flag.Arg(0)
flags.Usage() var cmd[]string
return nil if len(flag.Args()) >= 2 {
cmd = flag.Args()[1:]
}
// Choose a default image if needed
if name == "" {
name = "base"
}
// Choose a default command if needed
if len(cmd) == 0 {
*fl_stdin = true
*fl_tty = false
cmd = []string{"/bin/sh"}
} }
name, cmd := flags.Arg(0), flags.Args()[1:]
// Find the image // Find the image
img := srv.images.Find(name) img := srv.images.Find(name)
if img == nil { if img == nil {