'docker run' with no argument runs a shell in the base image
This commit is contained in:
parent
d5be77075a
commit
29410f43a0
1 changed files with 14 additions and 4 deletions
|
@ -597,11 +597,21 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
|||
if err := flags.Parse(args); err != nil {
|
||||
return nil
|
||||
}
|
||||
if flags.NArg() < 2 {
|
||||
flags.Usage()
|
||||
return nil
|
||||
name := flag.Arg(0)
|
||||
var cmd[]string
|
||||
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
|
||||
img := srv.images.Find(name)
|
||||
if img == nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue