diff --git a/api/client/commands.go b/api/client/commands.go index 01e7e6d743..d3e975739a 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -2299,77 +2299,3 @@ func (cli *DockerCli) CmdLoad(args ...string) error { } return nil } - -func (cli *DockerCli) CmdExec(args ...string) error { - cmd := cli.Subcmd("exec", "[OPTIONS] CONTAINER COMMAND [ARG...]", "Run a command in an existing container") - - execConfig, err := runconfig.ParseExec(cmd, args) - if err != nil { - return err - } - if execConfig.Container == "" { - cmd.Usage() - return nil - } - - if execConfig.Detach { - _, _, err := cli.call("POST", "/containers/"+execConfig.Container+"/exec", execConfig, false) - return err - } - var ( - out, stderr io.Writer - in io.ReadCloser - // We need to instanciate the chan because the select needs it. It can - // be closed but can't be uninitialized. - hijacked = make(chan io.Closer) - errCh chan error - ) - // Block the return until the chan gets closed - defer func() { - log.Debugf("End of CmdExec(), Waiting for hijack to finish.") - if _, ok := <-hijacked; ok { - log.Errorf("Hijack did not finish (chan still open)") - } - }() - - if execConfig.AttachStdin { - in = cli.in - } - if execConfig.AttachStdout { - out = cli.out - } - if execConfig.AttachStderr { - if execConfig.Tty { - stderr = cli.out - } else { - stderr = cli.err - } - } - errCh = utils.Go(func() error { - return cli.hijack("POST", "/containers/"+execConfig.Container+"/exec?", execConfig.Tty, in, out, stderr, hijacked, execConfig) - }) - - // Acknowledge the hijack before starting - select { - case closer := <-hijacked: - // Make sure that hijack gets closed when returning. (result - // in closing hijack chan and freeing server's goroutines. - if closer != nil { - defer closer.Close() - } - case err := <-errCh: - if err != nil { - log.Debugf("Error hijack: %s", err) - return err - } - } - // TODO(vishh): Enable tty size monitoring once the daemon can support that. - if errCh != nil { - if err := <-errCh; err != nil { - log.Debugf("Error hijack: %s", err) - return err - } - } - - return nil -} diff --git a/docs/man/docker-exec.md b/docs/man/docker-exec.md deleted file mode 100644 index 2a6979545b..0000000000 --- a/docs/man/docker-exec.md +++ /dev/null @@ -1,29 +0,0 @@ -% DOCKER(1) Docker User Manuals -% Docker Community -% SEPT 2014 -# NAME -docker-exec - Run a command in an existing container - -# SYNOPSIS -**docker exec** -[**-d**|**--detach**[=*false*]] -[**-i**|**--interactive**[=*false*]] -[**-t**|**--tty**[=*false*]] - CONTAINER COMMAND [ARG...] - -# DESCRIPTION - -Run a process in an existing container. The existing CONTAINER needs is active. - -# Options - -**-d**, **--detach**=*true*|*false* - Detached mode. This runs the new process in the background. - -**-i**, **--interactive**=*true*|*false* - When set to true, keep stdin open even if not attached. The default is false. - -**-t**, **--tty**=*true*|*false* - When set to true Docker can allocate a pseudo-tty and attach to the standard -input of the process. This can be used, for example, to run a throwaway -interactive shell. The default is value is false. diff --git a/docs/sources/reference/commandline/cli.md b/docs/sources/reference/commandline/cli.md index 7399585783..fcd12ee08d 100644 --- a/docs/sources/reference/commandline/cli.md +++ b/docs/sources/reference/commandline/cli.md @@ -1295,37 +1295,6 @@ It is even useful to cherry-pick particular tags of an image repository $ sudo docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy -## exec - - Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] - - Run a command in an existing container - - -d, --detach=false Detached mode: run the process in the background and exit - -i, --interactive=false Keep STDIN open even if not attached - -t, --tty=false Allocate a pseudo-TTY - -The `docker exec` command runs a user specified command as a new process in an existing -user specified container. The container needs to be active. - -The `docker exec` command will typically be used after `docker run`. - -### Examples: - - $ sudo docker run --name ubuntu_bash --rm -i -t ubuntu bash - -This will create a container named 'ubuntu_bash' and start a bash session. - - $ sudo docker exec -d ubuntu_bash touch /tmp/execWorks - -This will create a new file '/tmp/execWorks' inside the existing and active container -'ubuntu_bash', in the background. - - $ sudo docker exec ubuntu_bash -it bash - -This will create a new bash session in the container 'ubuntu_bash'. - - ## search Search [Docker Hub](https://hub.docker.com) for images