Browse code

Merge pull request #10508 from SvenDowideit/ctrl-backslash-used-to-generate-a-stacktrace

Remove docker attach generates a stacktrace on ctrl-\ docs, as i can't trigger it

Sven Dowideit authored on 2015/02/05 09:21:00
Showing 2 changed files
... ...
@@ -12,17 +12,19 @@ docker-attach - Attach to a running container
12 12
 CONTAINER
13 13
 
14 14
 # DESCRIPTION
15
-If you **docker run** a container in detached mode (**-d**), you can reattach to
16
-the detached container with **docker attach** using the container's ID or name.
15
+The **docker attach** command allows you to attach to a running container using
16
+the container's ID or name, either to view its ongoing output or to control it
17
+interactively.  You can attach to the same contained process multiple times
18
+simultaneously, screen sharing style, or quickly view the progress of your
19
+daemonized process.
17 20
 
18
-You can detach from the container again (and leave it running) with `CTRL-p 
19
-CTRL-q` (for a quiet exit), or `CTRL-c`  which will send a SIGKILL to the
20
-container, or `CTRL-\` to get a stacktrace of the Docker client when it quits.
21
-When you detach from a container the exit code will be returned to
22
-the client.
21
+You can detach from the container (and leave it running) with `CTRL-p CTRL-q`
22
+(for a quiet exit) or `CTRL-c` which will send a `SIGKILL` to the container.
23
+When you are attached to a container, and exit its main process, the process's
24
+exit code will be returned to the client.
23 25
 
24
-It is forbidden to redirect the standard input of a docker attach command while
25
-attaching to a tty-enabled container (i.e.: launched with -t`).
26
+It is forbidden to redirect the standard input of a `docker attach` command while
27
+attaching to a tty-enabled container (i.e.: launched with `-t`).
26 28
 
27 29
 # OPTIONS
28 30
 **--help**
... ...
@@ -426,29 +426,24 @@ Docker supports softlinks for the Docker data directory
426 426
       --no-stdin=false    Do not attach STDIN
427 427
       --sig-proxy=true    Proxy all received signals to the process
428 428
 
429
-The `attach` command lets you view or interact with any running container's
430
-primary process (`pid 1`).
429
+The `docker attach` command allows you to attach to a running container using
430
+the container's ID or name, either to view its ongoing output or to control it
431
+interactively.  You can attach to the same contained process multiple times
432
+simultaneously, screen sharing style, or quickly view the progress of your
433
+daemonized process.
431 434
 
432
-You can attach to the same contained process multiple times simultaneously, screen
433
-sharing style, or quickly view the progress of your daemonized process.
435
+You can detach from the container (and leave it running) with `CTRL-p CTRL-q`
436
+(for a quiet exit) or `CTRL-c` which will send a `SIGKILL` to the container.
437
+When you are attached to a container, and exit its main process, the process's
438
+exit code will be returned to the client.
434 439
 
435
-> **Note:** This command is not for running a new process in a container.
436
-> See: [`docker exec`](#exec).
437
-
438
-You can detach from the container again (and leave it running) with
439
-`CTRL-p CTRL-q` (for a quiet exit), or `CTRL-c`  which will send a
440
-SIGKILL to the container, or `CTRL-\` to get a stacktrace of the
441
-Docker client when it quits. When you detach from the container's
442
-process the exit code will be returned to the client.
443
-
444
-To stop a container, use `docker stop`.
445
-
446
-To kill the container, use `docker kill`.
440
+It is forbidden to redirect the standard input of a `docker attach` command while
441
+attaching to a tty-enabled container (i.e.: launched with `-t`).
447 442
 
448 443
 #### Examples
449 444
 
450
-    $ ID=$(sudo docker run -d ubuntu /usr/bin/top -b)
451
-    $ sudo docker attach $ID
445
+    $ sudo docker run -d --name topdemo ubuntu /usr/bin/top -b)
446
+    $ sudo docker attach topdemo
452 447
     top - 02:05:52 up  3:05,  0 users,  load average: 0.01, 0.02, 0.05
453 448
     Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
454 449
     Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
... ...
@@ -477,7 +472,23 @@ To kill the container, use `docker kill`.
477 477
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
478 478
           1 root      20   0 17208 1144  932 R    0  0.3   0:00.03 top
479 479
     ^C$
480
-    $ sudo docker stop $ID
480
+    $ echo $?
481
+    0
482
+    $ docker ps -a | grep topdemo
483
+    7998ac8581f9        ubuntu:14.04        "/usr/bin/top -b"   38 seconds ago      Exited (0) 21 seconds ago                          topdemo 
484
+
485
+And in this second example, you can see the exit code returned by the `bash` process
486
+is returned by the `docker attach` command to its caller too:
487
+
488
+    $ sudo docker run --name test -d -it debian
489
+    275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
490
+    $ sudo docker attach test
491
+    $$ exit 13
492
+    exit
493
+    $ echo $?
494
+    13
495
+    $ sudo docker ps -a | grep test
496
+    275c44472aeb        debian:7            "/bin/bash"         26 seconds ago      Exited (13) 17 seconds ago                         test
481 497
 
482 498
 ## build
483 499
 
... ...
@@ -1651,6 +1662,19 @@ and linking containers.
1651 1651
 
1652 1652
 #### Examples
1653 1653
 
1654
+    $ sudo docker run --name test -it debian
1655
+    $$ exit 13
1656
+    exit
1657
+    $ echo $?
1658
+    13
1659
+    $ sudo docker ps -a | grep test
1660
+    275c44472aeb        debian:7            "/bin/bash"         26 seconds ago      Exited (13) 17 seconds ago                         test
1661
+
1662
+In this example, we are running `bash` interactively in the `debian:latest` image, and giving
1663
+the container the name `test`. We then quit `bash` by running `exit 13`, which means `bash`
1664
+will have an exit code of `13`. This is then passed on to the caller of `docker run`, and
1665
+is recorded in the `test` container metadata.
1666
+
1654 1667
     $ sudo docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
1655 1668
 
1656 1669
 This will create a container and print `test` to the console. The `cidfile`