github.com/georgethebeatle/containerd@v0.2.5/docs/attach.md (about) 1 # Attaching to STDIO or TTY 2 3 The model for STDIO, TTY, and logging is a little different in containerd. 4 Because of the various methods that consumers want on the logging side these types of decisions 5 are pushed to the client. 6 Containerd API is developed for access on a single host therefore many things like paths on the host system are acceptable in the API. 7 For the STDIO model the client requesting to start a container provides the paths for the IO. 8 9 ## Logging 10 11 If no options are specified on create all STDIO of the processes launched by containerd will be sent to `/dev/null`. 12 If you want containerd to send the STDIO of the processes to a file, you can pass paths to the files in the create container method defined by this proto in the stdin, stdout, and stderr fields: 13 14 ```proto 15 message CreateContainerRequest { 16 string id = 1; // ID of container 17 string bundlePath = 2; // path to OCI bundle 18 string stdin = 3; // path to the file where stdin will be read (optional) 19 string stdout = 4; // path to file where stdout will be written (optional) 20 string stderr = 5; // path to file where stderr will be written (optional) 21 string console = 6; // path to the console for a container (optional) 22 string checkpoint = 7; // checkpoint name if you want to create immediate checkpoint (optional) 23 } 24 ``` 25 26 ## Attach 27 28 In order to have attach like functionality for your containers you use the same API request but named pipes or fifos can be used to achieve this type of functionality. 29 The default CLI for containerd does this if you specify the `--attach` flag on `create` or `start`. 30 It will create fifos for each of the containers stdio which the CLI can read and write to. 31 This can be used to create an interactive session with the container, `bash` for example, or to have a blocking way to collect the container's STDIO and forward it to your logging facilities. 32 33 ## TTY 34 35 The tty model is the same as above only the client creates a pty and provides to other side to containerd in the create request in the `console` field. 36 Containerd will provide the pty to the container to use and the session can be opened with the container after it starts.