github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/Documentation/subcommands/attach.md (about)

     1  # rkt attach
     2  
     3  Applications can be started in interactive mode and later attached via `rkt attach`.
     4  
     5  In order for an application to be attachable:
     6   * it must be started in interactive mode
     7   * it must be running as part of a running pod
     8   * it must support the corresponding attach mode
     9  
    10  To start an application in interactive mode, either `tty` or `stream` must be passed as value for the `--stdin`, `--stdout` and `--stderr` options.
    11  
    12  An application can be run with a dedicated terminal and later attached to:
    13  
    14  ```
    15  # rkt run quay.io/coreos/alpine-sh --stdin tty --stdout tty --stderr tty
    16  ```
    17  
    18  ```
    19  # rkt attach --mode tty ${UUID}
    20  
    21  / # hostname
    22  rkt-911afe8e-992f-4089-8666-4a4c957a1964
    23  
    24  / # tty     
    25  /rkt/iottymux/alpine-sh/pts
    26  ^C
    27  ```
    28  
    29  In a similar way, an application can be run without a tty but with separated attachable streams:
    30  
    31  ```
    32  # rkt run quay.io/coreos/alpine-sh --stdin stream --stdout stream --stderr stream
    33  ```
    34  
    35  ```
    36  # rkt attach --mode stdin,stdout,stderr ${UUID}
    37  hostname
    38  rkt-846c35db-6728-471a-ad50-66d3a8d7ff9c
    39  
    40  tty
    41  not a tty
    42  ^C
    43  ```
    44  
    45  If a pod contains multiple applications, the one to be used as attach target can be specified via `--app`.
    46  
    47  The following options are allowed as `--mode` values:
    48   * `list`: list available endpoints, and return early without attaching
    49   * `auto`: attach to all available endpoints
    50   * `tty`: bi-directionally attach to the application terminal
    51   * `tty-in` or `tty-out`: uni-directionally attach to the application terminal
    52   * `stdin,stdout,stderr`: attach to specific application streams. Omitted streams will no be attached
    53  
    54  A more complex example, showing the usage of advanced options and piping:
    55  
    56  ```
    57  # rkt run quay.io/coreos/alpine-sh --stdin stream --stdout stream --stderr stream
    58  ```
    59  
    60  ```
    61  # rkt attach --app alpine-sh --mode list 846c35db
    62  stdin
    63  stdout
    64  stderr
    65  
    66  # echo 'hostname; fakecmd' | ./rkt attach --app alpine-sh --mode auto ${UUID}
    67  rkt-846c35db-6728-471a-ad50-66d3a8d7ff9c
    68  /bin/sh: fakecmd: not found
    69  ^C
    70  
    71  # echo 'hostname; fakecmd' | ./rkt attach --app alpine-sh --mode stdin,stdout ${UUID}
    72  rkt-846c35db-6728-471a-ad50-66d3a8d7ff9c
    73  ^C
    74  
    75  # echo 'hostname; fakecmd' | ./rkt attach --app alpine-sh --mode stdin,stderr ${UUID}
    76  /bin/sh: fakecmd: not found
    77  ^C
    78  ```
    79  
    80  ## Options
    81  
    82  | Flag | Default | Options | Description |
    83  | ---  | ---     | ---     | ---         |
    84  | `--app`  |  ``     | Name of an application            | Name of the app to attach to within the specified pod |
    85  | `--mode` |  `auto` | "list", "auto" or tty/stream mode | Attaching mode                                        |
    86  
    87  ## Global options
    88  
    89  See the table with [global options in general commands documentation][global-options].
    90  
    91  
    92  [global-options]: ../commands.md#global-options