#175 Add autodownload on run command
This commit is contained in:
parent
53641e8b8d
commit
91d78a10c3
1 changed files with 10 additions and 1 deletions
11
commands.go
11
commands.go
|
@ -826,10 +826,19 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
|||
fmt.Fprintln(stdout, "Error: Command not specified")
|
||||
return fmt.Errorf("Command not specified")
|
||||
}
|
||||
|
||||
// Create new container
|
||||
container, err := srv.runtime.Create(config)
|
||||
if err != nil {
|
||||
return errors.New("Error creating container: " + err.Error())
|
||||
// If container not found, try to pull it
|
||||
// FIXME: not found != error
|
||||
fmt.Fprintf(stdout, "Image %s not found, trying to pull it from registry.\n", config.Image)
|
||||
if err = srv.CmdPull(stdin, stdout, config.Image); err != nil {
|
||||
return err
|
||||
}
|
||||
if container, err = srv.runtime.Create(config); err != nil {
|
||||
return fmt.Errorf("Error creating container: %s", err)
|
||||
}
|
||||
}
|
||||
if config.OpenStdin {
|
||||
cmd_stdin, err := container.StdinPipe()
|
||||
|
|
Loading…
Add table
Reference in a new issue