github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/man/src/container/attach.md (about) 1 The **docker attach** command allows you to attach to a running container using 2 the container's ID or name, either to view its ongoing output or to control it 3 interactively. You can attach to the same contained process multiple times 4 simultaneously, screen sharing style, or quickly view the progress of your 5 detached process. 6 7 To stop a container, use `CTRL-c`. This key sequence sends **SIGKILL** to the 8 container. You can detach from the container (and leave it running) using a 9 configurable key sequence. The default sequence is `CTRL-p CTRL-q`. You 10 configure the key sequence using the **--detach-keys** option or a configuration 11 file. See **config-json(5)** for documentation on using a configuration file. 12 13 It is forbidden to redirect the standard input of a **docker attach** command while 14 attaching to a TTY-enabled container (i.e., launched with `-i` and `-t`). 15 16 # Override the detach sequence 17 18 If you want, you can configure an override the Docker key sequence for detach. 19 This is useful if the Docker default sequence conflicts with key sequence you 20 use for other applications. There are two ways to define your own detach key 21 sequence, as a per-container override or as a configuration property on your 22 entire configuration. 23 24 To override the sequence for an individual container, use the 25 **--detach-keys**=*key* flag with the **docker attach** command. The format of 26 the *key* is either a letter [a-Z], or the **ctrl**-*value*, where *value* is one 27 of the following: 28 29 * **a-z** (a single lowercase alpha character ) 30 * **@** (at sign) 31 * **[** (left bracket) 32 * **\\\\** (two backward slashes) 33 * **_** (underscore) 34 * **^** (caret) 35 36 These **a**, **ctrl-a**, **X**, or **ctrl-\\** values are all examples of valid key 37 sequences. To configure a different configuration default key sequence for all 38 containers, see **docker(1)**. 39 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