Skip to content

Commit 33c7baa

Browse files
authored
Merge pull request #4336 from thaJeztah/move_attach_keys
docs: move "--detach-keys" example to examples section, add to "docker run" as well
2 parents 1db37a8 + 47951ff commit 33c7baa

3 files changed

Lines changed: 76 additions & 51 deletions

File tree

docs/reference/commandline/attach.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Attach local standard input, output, and error streams to a running container
99

1010
### Options
1111

12-
| Name | Type | Default | Description |
13-
|:----------------|:---------|:--------|:----------------------------------------------------|
14-
| `--detach-keys` | `string` | | Override the key sequence for detaching a container |
15-
| `--no-stdin` | | | Do not attach STDIN |
16-
| `--sig-proxy` | | | Proxy all received signals to the process |
12+
| Name | Type | Default | Description |
13+
|:--------------------------------|:---------|:--------|:----------------------------------------------------|
14+
| [`--detach-keys`](#detach-keys) | `string` | | Override the key sequence for detaching a container |
15+
| `--no-stdin` | | | Do not attach STDIN |
16+
| `--sig-proxy` | | | Proxy all received signals to the process |
1717

1818

1919
<!---MARKER_GEN_END-->
@@ -56,30 +56,6 @@ performance critical applications that generate a lot of output in the
5656
foreground over a slow client connection. Instead, users should use the
5757
`docker logs` command to get access to the logs.
5858

59-
### Override the detach sequence
60-
61-
If you want, you can configure an override the Docker key sequence for detach.
62-
This is useful if the Docker default sequence conflicts with key sequence you
63-
use for other applications. There are two ways to define your own detach key
64-
sequence, as a per-container override or as a configuration property on your
65-
entire configuration.
66-
67-
To override the sequence for an individual container, use the
68-
`--detach-keys="<sequence>"` flag with the `docker attach` command. The format of
69-
the `<sequence>` is either a letter [a-Z], or the `ctrl-` combined with any of
70-
the following:
71-
72-
* `a-z` (a single lowercase alpha character )
73-
* `@` (at sign)
74-
* `[` (left bracket)
75-
* `\\` (two backward slashes)
76-
* `_` (underscore)
77-
* `^` (caret)
78-
79-
These `a`, `ctrl-a`, `X`, or `ctrl-\\` values are all examples of valid key
80-
sequences. To configure a different configuration default key sequence for all
81-
containers, see [**Configuration file** section](cli.md#configuration-files).
82-
8359
## Examples
8460

8561
### Attach to and detach from a running container
@@ -168,3 +144,27 @@ $ docker ps -a --filter name=test
168144
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
169145
a2fe3fd886db alpine "/bin/sh" About a minute ago Exited (13) 40 seconds ago test
170146
```
147+
148+
### <a name="detach-keys"></a> Override the detach sequence (--detach-keys)
149+
150+
Use the `--detach-keys` option to override the Docker key sequence for detach.
151+
This is useful if the Docker default sequence conflicts with key sequence you
152+
use for other applications. There are two ways to define your own detach key
153+
sequence, as a per-container override or as a configuration property on your
154+
entire configuration.
155+
156+
To override the sequence for an individual container, use the
157+
`--detach-keys="<sequence>"` flag with the `docker attach` command. The format of
158+
the `<sequence>` is either a letter [a-Z], or the `ctrl-` combined with any of
159+
the following:
160+
161+
* `a-z` (a single lowercase alpha character )
162+
* `@` (at sign)
163+
* `[` (left bracket)
164+
* `\\` (two backward slashes)
165+
* `_` (underscore)
166+
* `^` (caret)
167+
168+
These `a`, `ctrl-a`, `X`, or `ctrl-\\` values are all examples of valid key
169+
sequences. To configure a different configuration default key sequence for all
170+
containers, see [**Configuration file** section](cli.md#configuration-files).

docs/reference/commandline/run.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Create and run a new container from an image
3232
| `--cpuset-cpus` | `string` | | CPUs in which to allow execution (0-3, 0,1) |
3333
| `--cpuset-mems` | `string` | | MEMs in which to allow execution (0-3, 0,1) |
3434
| `-d`, `--detach` | | | Run container in background and print container ID |
35-
| `--detach-keys` | `string` | | Override the key sequence for detaching a container |
35+
| [`--detach-keys`](#detach-keys) | `string` | | Override the key sequence for detaching a container |
3636
| [`--device`](#device) | `list` | | Add a host device to the container |
3737
| [`--device-cgroup-rule`](#device-cgroup-rule) | `list` | | Add a rule to the cgroup allowed devices list |
3838
| `--device-read-bps` | `list` | | Limit read rate (bytes per second) from a device |
@@ -569,6 +569,30 @@ retrieve the container's ID once the container has finished running.
569569

570570
See also [the `docker cp` command](cp.md).
571571

572+
### <a name="detach-keys"></a> Override the detach sequence (--detach-keys)
573+
574+
Use the `--detach-keys` option to override the Docker key sequence for detach.
575+
This is useful if the Docker default sequence conflicts with key sequence you
576+
use for other applications. There are two ways to define your own detach key
577+
sequence, as a per-container override or as a configuration property on your
578+
entire configuration.
579+
580+
To override the sequence for an individual container, use the
581+
`--detach-keys="<sequence>"` flag with the `docker attach` command. The format of
582+
the `<sequence>` is either a letter [a-Z], or the `ctrl-` combined with any of
583+
the following:
584+
585+
* `a-z` (a single lowercase alpha character )
586+
* `@` (at sign)
587+
* `[` (left bracket)
588+
* `\\` (two backward slashes)
589+
* `_` (underscore)
590+
* `^` (caret)
591+
592+
These `a`, `ctrl-a`, `X`, or `ctrl-\\` values are all examples of valid key
593+
sequences. To configure a different configuration default key sequence for all
594+
containers, see [**Configuration file** section](cli.md#configuration-files).
595+
572596
### <a name="device"></a> Add host device to container (--device)
573597

574598
```console

man/src/container/attach.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,29 @@ file. See **config-json(5)** for documentation on using a configuration file.
1313
It is forbidden to redirect the standard input of a **docker attach** command while
1414
attaching 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.
1939
This is useful if the Docker default sequence conflicts with key sequence you
2040
use for other applications. There are two ways to define your own detach key
2141
sequence, 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
3757
sequences. To configure a different configuration default key sequence for all
3858
containers, 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

Comments
 (0)