From 1fe1b216ad9b60f6b25a5dadda5fe26c3602b054 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 27 Nov 2013 17:10:20 -0800 Subject: [PATCH] Return process exit code for attach Fixes #2240 --- commands.go | 9 +++++++++ docs/sources/commandline/cli.rst | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index d992db2e6c..d52a463638 100644 --- a/commands.go +++ b/commands.go @@ -1578,6 +1578,15 @@ func (cli *DockerCli) CmdAttach(args ...string) error { if err := cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), container.Config.Tty, in, cli.out, cli.err, nil); err != nil { return err } + + _, status, err := getExitCode(cli, cmd.Arg(0)) + if err != nil { + return err + } + if status != 0 { + return &utils.StatusError{Status: status} + } + return nil } diff --git a/docs/sources/commandline/cli.rst b/docs/sources/commandline/cli.rst index 9635675a77..01f839736a 100644 --- a/docs/sources/commandline/cli.rst +++ b/docs/sources/commandline/cli.rst @@ -66,7 +66,8 @@ To run the daemon with debug output, use ``docker -d -D`` You can detach from the container again (and leave it running) with ``CTRL-c`` (for a quiet exit) or ``CTRL-\`` to get a stacktrace of -the Docker client when it quits. +the Docker client when it quits. When you detach from the container's +process the exit code will be retuned to the client. To stop a container, use ``docker stop``