Deprecated 'docker run -a'. Containers are run in the foreground by default. '-d' enables detached mode

This commit is contained in:
Solomon Hykes 2013-03-22 20:46:14 -07:00
parent 34fbaa5f6d
commit 841c7ac0f9
2 changed files with 7 additions and 8 deletions

View File

@ -76,7 +76,7 @@ Installing on Ubuntu 12.04 and 12.10
```bash
cd docker-master
sudo ./docker run -a -i -t base /bin/bash
sudo ./docker run -i -t base /bin/bash
```
Consider adding docker to your `PATH` for simplicity.
@ -136,7 +136,7 @@ docker import base
# Run an interactive shell in the base image,
# allocate a tty, attach stdin and stdout
docker run -a -i -t base /bin/bash
docker run -i -t base /bin/bash
```
@ -148,7 +148,7 @@ Starting a long-running worker process
(docker -d || echo "Docker daemon already running") &
# Start a very useful long-running process
JOB=$(docker run base /bin/sh -c "while true; do echo Hello world; sleep 1; done")
JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done")
# Collect the output of the job so far
docker logs $JOB
@ -171,7 +171,7 @@ Expose a service on a TCP port
```bash
# Expose port 4444 of this container, and tell netcat to listen on it
JOB=$(docker run -p 4444 base /bin/nc -l -p 4444)
JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
# Which public port is NATed to my container?
PORT=$(docker port $JOB 4444)

View File

@ -794,7 +794,7 @@ func (srv *Server) CmdTag(stdin io.ReadCloser, stdout io.Writer, args ...string)
func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
cmd := rcli.Subcmd(stdout, "run", "[OPTIONS] IMAGE COMMAND [ARG...]", "Run a command in a new container")
fl_user := cmd.String("u", "", "Username or UID")
fl_attach := cmd.Bool("a", false, "Attach stdin and stdout")
fl_detach := cmd.Bool("d", false, "Detached mode: leave the container running in the background")
fl_stdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
fl_tty := cmd.Bool("t", false, "Allocate a pseudo-tty")
fl_memory := cmd.Int64("m", 0, "Memory limit (in bytes)")
@ -821,7 +821,6 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
if len(cmdline) == 0 {
*fl_stdin = true
*fl_tty = true
*fl_attach = true
cmdline = []string{"/bin/bash", "-i"}
}
@ -843,7 +842,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
if err != nil {
return err
}
if *fl_attach {
if !*fl_detach {
Go(func() error {
_, err := io.Copy(cmd_stdin, stdin)
cmd_stdin.Close()
@ -852,7 +851,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
}
}
// Run the container
if *fl_attach {
if !*fl_detach {
cmd_stderr, err := container.StderrPipe()
if err != nil {
return err