github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/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 `-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="<sequence>"` flag with the `docker attach` command. The format of
    26  the `<sequence>` is either a letter [a-Z], or the `ctrl-` combined with any of
    27  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 image called
    45  fedora, in detached mode. The ID from the container is passed into the **docker
    46  attach** command:
    47  
    48      $ ID=$(sudo docker run -d fedora /usr/bin/top -b)
    49      $ sudo docker attach $ID
    50      top - 02:05:52 up  3:05,  0 users,  load average: 0.01, 0.02, 0.05
    51      Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
    52      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
    53      Mem:    373572k total,   355560k used,    18012k free,    27872k buffers
    54      Swap:   786428k total,        0k used,   786428k free,   221740k cached
    55  
    56      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    57      1 root      20   0 17200 1116  912 R    0  0.3   0:00.03 top
    58  
    59      top - 02:05:55 up  3:05,  0 users,  load average: 0.01, 0.02, 0.05
    60      Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
    61      Cpu(s):  0.0%us,  0.2%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    62      Mem:    373572k total,   355244k used,    18328k free,    27872k buffers
    63      Swap:   786428k total,        0k used,   786428k free,   221776k cached
    64  
    65      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    66      1 root      20   0 17208 1144  932 R    0  0.3   0:00.03 top