docker attach
1 概述
docker attach
命令将容器的标准输入,标准输出,标准错误,打印到当前宿主机的终端。
2 语法大纲
$ docker attach --help
Usage: docker attach [OPTIONS] CONTAINER
Attach local standard input, output, and error streams to a running container
Options:
--detach-keys string Override the key sequence for detaching a container
--no-stdin Do not attach STDIN
--sig-proxy Proxy all received signals to the process (default true)
2.1 参数简介
参数 | 说明 |
---|---|
--detach-keys string | 指定退出 attach 模式的快捷键序列,默认是 CTRL-p CTRL-q。 |
--no-stdin | 否关闭标准输入,默认是保持打开。 |
--sig-proxy | 否代理收到的系统信号给应用进程,默认为true |
2.2 打印容器终端信息
docker attach kcp_centos
Note
- 使用先按
CTRL + P
后立即按住CTRL + Q
退出 attach。
- 在生产环境中同时使用 attach 命令连接到同一个容器时候,所有窗口都会同步显示。这样多有不便。为了解决这个问题,新增了
docker exec
命令。