зеркало из https://github.com/microsoft/docker.git
docker run -a: optionally attach to the new process. Run it in the background by default
This commit is contained in:
Родитель
63081c6cc8
Коммит
e74d0b2a56
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -237,6 +238,7 @@ func (docker *Docker) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...stri
|
||||||
flags := Subcmd(stdout, "run", "-l LAYER [-l LAYER...] COMMAND {ARG...]", "Run a command in a container")
|
flags := Subcmd(stdout, "run", "-l LAYER [-l LAYER...] COMMAND {ARG...]", "Run a command in a container")
|
||||||
fl_layers := new(ArgList)
|
fl_layers := new(ArgList)
|
||||||
flags.Var(fl_layers, "l", "Add a layer to the filesystem. Multiple layers are added in the order they are defined")
|
flags.Var(fl_layers, "l", "Add a layer to the filesystem. Multiple layers are added in the order they are defined")
|
||||||
|
fl_attach := flags.Bool("a", false, "Attach stdin and stdout")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := flags.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -278,7 +280,13 @@ func (docker *Docker) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...stri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
docker.containers[container.Id] = container
|
docker.containers[container.Id] = container
|
||||||
return container.Run(stdin, stdout)
|
if *fl_attach {
|
||||||
|
return container.Run(stdin, stdout)
|
||||||
|
} else {
|
||||||
|
go container.Run(ioutil.NopCloser(new(bytes.Buffer)), ioutil.Discard)
|
||||||
|
fmt.Fprintln(stdout, container.Id)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (docker *Docker) CmdClone(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (docker *Docker) CmdClone(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче