@@ -13,9 +13,29 @@ file. See **config-json(5)** for documentation on using a configuration file.
1313It is forbidden to redirect the standard input of a ** docker attach** command while
1414attaching to a TTY-enabled container (i.e., launched with ` -i ` and ` -t ` ).
1515
16- # Override the detach sequence
16+ # EXAMPLES
17+
18+ ## Attaching to a container
19+
20+ In this example the top command is run inside a container from an ubuntu image,
21+ in detached mode, then attaches to it, and then terminates the container
22+ with ` CTRL-c ` :
23+
24+ $ docker run -d --name topdemo ubuntu:20.04 /usr/bin/top -b
25+ $ docker attach topdemo
26+ top - 00:07:01 up 4:54, 0 users, load average: 0.83, 0.91, 0.82
27+ Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
28+ %Cpu(s): 2.3 us, 1.6 sy, 0.0 ni, 95.9 id, 0.0 wa, 0.1 hi, 0.1 si, 0.0 st
29+ MiB Mem : 15846.2 total, 5729.2 free, 2592.5 used, 7524.4 buff/cache
30+ MiB Swap: 16384.0 total, 16384.0 free, 0.0 used. 12097.3 avail Mem
31+
32+ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
33+ 1 root 20 0 5976 3256 2828 R 0.0 0.0 0:00.04 top
34+ ^C
35+
36+ ## Override the detach sequence
1737
18- If you want, you can configure an override the Docker key sequence for detach.
38+ Use the ** --detach-keys ** option to override the Docker key sequence for detach.
1939This is useful if the Docker default sequence conflicts with key sequence you
2040use for other applications. There are two ways to define your own detach key
2141sequence, as a per-container override or as a configuration property on your
@@ -37,22 +57,3 @@ These **a**, **ctrl-a**, **X**, or **ctrl-\\** values are all examples of valid
3757sequences. To configure a different configuration default key sequence for all
3858containers, see ** docker(1)** .
3959
40- # EXAMPLES
41-
42- ## Attaching to a container
43-
44- In this example the top command is run inside a container from an ubuntu image,
45- in detached mode, then attaches to it, and then terminates the container
46- with ` CTRL-c ` :
47-
48- $ docker run -d --name topdemo ubuntu:20.04 /usr/bin/top -b
49- $ docker attach topdemo
50- top - 00:07:01 up 4:54, 0 users, load average: 0.83, 0.91, 0.82
51- Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
52- %Cpu(s): 2.3 us, 1.6 sy, 0.0 ni, 95.9 id, 0.0 wa, 0.1 hi, 0.1 si, 0.0 st
53- MiB Mem : 15846.2 total, 5729.2 free, 2592.5 used, 7524.4 buff/cache
54- MiB Swap: 16384.0 total, 16384.0 free, 0.0 used. 12097.3 avail Mem
55-
56- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
57- 1 root 20 0 5976 3256 2828 R 0.0 0.0 0:00.04 top
58- ^C
0 commit comments