зеркало из https://github.com/microsoft/docker.git
Address review comments.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
Родитель
d980589de6
Коммит
669561c2aa
|
@ -25,14 +25,14 @@ func (cli *DockerCli) dial() (net.Conn, error) {
|
|||
return net.Dial(cli.proto, cli.addr)
|
||||
}
|
||||
|
||||
func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.ReadCloser, stdout, stderr io.Writer, started chan io.Closer, body interface{}) error {
|
||||
func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.ReadCloser, stdout, stderr io.Writer, started chan io.Closer, data interface{}) error {
|
||||
defer func() {
|
||||
if started != nil {
|
||||
close(started)
|
||||
}
|
||||
}()
|
||||
|
||||
params, err := cli.getUrlBody(body)
|
||||
params, err := cli.encodeData(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ func (cli *DockerCli) HTTPClient() *http.Client {
|
|||
return &http.Client{Transport: tr}
|
||||
}
|
||||
|
||||
func (cli *DockerCli) getUrlBody(data interface{}) (*bytes.Buffer, error) {
|
||||
func (cli *DockerCli) encodeData(data interface{}) (*bytes.Buffer, error) {
|
||||
params := bytes.NewBuffer(nil)
|
||||
if data != nil {
|
||||
if env, ok := data.(engine.Env); ok {
|
||||
|
@ -61,7 +61,7 @@ func (cli *DockerCli) getUrlBody(data interface{}) (*bytes.Buffer, error) {
|
|||
}
|
||||
|
||||
func (cli *DockerCli) call(method, path string, data interface{}, passAuthInfo bool) (io.ReadCloser, int, error) {
|
||||
params, err := cli.getUrlBody(data)
|
||||
params, err := cli.encodeData(data)
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t
|
|||
|
||||
// Connect stdin of container to the http conn.
|
||||
if stdin != nil && openStdin {
|
||||
nJobs += 1
|
||||
nJobs++
|
||||
// Get the stdin pipe.
|
||||
if cStdin, err := streamConfig.StdinPipe(); err != nil {
|
||||
errors <- err
|
||||
|
@ -166,7 +166,7 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t
|
|||
}
|
||||
}
|
||||
if stdout != nil {
|
||||
nJobs += 1
|
||||
nJobs++
|
||||
// Get a reader end of a pipe that is attached as stdout to the container.
|
||||
if p, err := streamConfig.StdoutPipe(); err != nil {
|
||||
errors <- err
|
||||
|
@ -260,7 +260,7 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t
|
|||
|
||||
// FIXME: how to clean up the stdin goroutine without the unwanted side effect
|
||||
// of closing the passed stdin? Add an intermediary io.Pipe?
|
||||
for i := 0; i < nJobs; i += 1 {
|
||||
for i := 0; i < nJobs; i++ {
|
||||
log.Debugf("attach: waiting for job %d/%d", i+1, nJobs)
|
||||
if err := <-errors; err != nil {
|
||||
log.Errorf("attach: job %d returned error %s, aborting all jobs", i+1, err)
|
||||
|
|
|
@ -24,7 +24,7 @@ type ExecConfig struct {
|
|||
|
||||
func (d *Daemon) ContainerExec(job *engine.Job) engine.Status {
|
||||
if len(job.Args) != 1 {
|
||||
return job.Errorf("Usage: %s container_id command", job.Name)
|
||||
return job.Errorf("Usage: %s [options] container command [args]", job.Name)
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -40,7 +40,7 @@ func (d *Daemon) ContainerExec(job *engine.Job) engine.Status {
|
|||
return job.Errorf("No such container: %s", name)
|
||||
}
|
||||
|
||||
if !container.State.IsRunning() {
|
||||
if !container.IsRunning() {
|
||||
return job.Errorf("Container %s is not not running", name)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,16 @@ import (
|
|||
"github.com/docker/libcontainer/namespaces"
|
||||
)
|
||||
|
||||
const commandName = "nsenter-exec"
|
||||
const execCommandName = "nsenter-exec"
|
||||
|
||||
func init() {
|
||||
reexec.Register(commandName, nsenterExec)
|
||||
reexec.Register(execCommandName, nsenterExec)
|
||||
}
|
||||
|
||||
func nsenterExec() {
|
||||
runtime.LockOSThread()
|
||||
|
||||
// User args are passed after '--' in the command line.
|
||||
userArgs := findUserArgs()
|
||||
|
||||
config, err := loadConfigFromFd()
|
||||
|
|
|
@ -10,16 +10,12 @@ import (
|
|||
)
|
||||
|
||||
func findUserArgs() []string {
|
||||
i := 0
|
||||
for _, a := range os.Args {
|
||||
i++
|
||||
|
||||
for i, a := range os.Args {
|
||||
if a == "--" {
|
||||
break
|
||||
return os.Args[i+1:]
|
||||
}
|
||||
}
|
||||
|
||||
return os.Args[i:]
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// loadConfigFromFd loads a container's config from the sync pipe that is provided by
|
||||
|
|
|
@ -1297,7 +1297,7 @@ It is even useful to cherry-pick particular tags of an image repository
|
|||
|
||||
## exec
|
||||
|
||||
Usage: docker exec CONTAINER COMMAND [ARG...]
|
||||
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
|
||||
|
||||
Run a command in an existing container
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ func ExecConfigFromJob(job *engine.Job) *ExecConfig {
|
|||
AttachStderr: job.GetenvBool("AttachStderr"),
|
||||
AttachStdout: job.GetenvBool("AttachStdout"),
|
||||
}
|
||||
if Cmd := job.GetenvList("Cmd"); Cmd != nil {
|
||||
execConfig.Cmd = Cmd
|
||||
if cmd := job.GetenvList("Cmd"); cmd != nil {
|
||||
execConfig.Cmd = cmd
|
||||
}
|
||||
|
||||
return execConfig
|
||||
|
|
Загрузка…
Ссылка в новой задаче