mirror of https://github.com/docker/cli.git
Implement configurable detach key
Implement configurable detach keys (for `attach`, exec`, `run` and `start`) using the client-side configuration - Adds a `--detach-keys` flag to `attach`, `exec`, `run` and `start` commands. - Adds a new configuration field (in `~/.docker/config.json`) to configure the default escape keys for docker client. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
351710a2bb
commit
18eb9f2e64
|
@ -14,9 +14,10 @@ parent = "smn_cli"
|
||||||
|
|
||||||
Attach to a running container
|
Attach to a running container
|
||||||
|
|
||||||
--help Print usage
|
--detach-keys="<sequence>" Set up escape key sequence
|
||||||
--no-stdin Do not attach STDIN
|
--help Print usage
|
||||||
--sig-proxy=true Proxy all received signals to the process
|
--no-stdin Do not attach STDIN
|
||||||
|
--sig-proxy=true Proxy all received signals to the process
|
||||||
|
|
||||||
The `docker attach` command allows you to attach to a running container using
|
The `docker attach` command allows you to attach to a running container using
|
||||||
the container's ID or name, either to view its ongoing output or to control it
|
the container's ID or name, either to view its ongoing output or to control it
|
||||||
|
@ -24,11 +25,10 @@ interactively. You can attach to the same contained process multiple times
|
||||||
simultaneously, screen sharing style, or quickly view the progress of your
|
simultaneously, screen sharing style, or quickly view the progress of your
|
||||||
detached process.
|
detached process.
|
||||||
|
|
||||||
You can detach from the container and leave it running with `CTRL-p CTRL-q`
|
To stop a container, use `CTRL-c`. This key sequence sends `SIGKILL` to the
|
||||||
(for a quiet exit) or with `CTRL-c` if `--sig-proxy` is false.
|
container. If `--sig-proxy` is true (the default),`CTRL-c` sends a `SIGINT` to
|
||||||
|
the container. You can detach from a container and leave it running using the
|
||||||
If `--sig-proxy` is true (the default),`CTRL-c` sends a `SIGINT` to the
|
using `CTRL-p CTRL-q` key sequence.
|
||||||
container.
|
|
||||||
|
|
||||||
> **Note:**
|
> **Note:**
|
||||||
> A process running as PID 1 inside a container is treated specially by
|
> A process running as PID 1 inside a container is treated specially by
|
||||||
|
@ -39,6 +39,31 @@ container.
|
||||||
It is forbidden to redirect the standard input of a `docker attach` command
|
It is forbidden to redirect the standard input of a `docker attach` command
|
||||||
while attaching to a tty-enabled container (i.e.: launched with `-t`).
|
while attaching to a tty-enabled container (i.e.: launched with `-t`).
|
||||||
|
|
||||||
|
|
||||||
|
## Override the detach sequence
|
||||||
|
|
||||||
|
If you want, you can configure a override the Docker key sequence for detach.
|
||||||
|
This is is useful if the Docker default sequence conflicts with key squence you
|
||||||
|
use for other applications. There are two ways to defines a your own detach key
|
||||||
|
sequence, as a per-container override or as a configuration property on your
|
||||||
|
entire configuration.
|
||||||
|
|
||||||
|
To override the sequence for an individual container, use the
|
||||||
|
`--detach-keys="<sequence>"` flag with the `docker attach` command. The format of
|
||||||
|
the `<sequence>` is either a letter [a-Z], or the `ctrl-` combined with any of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
* `a-z` (a single lowercase alpha character )
|
||||||
|
* `@` (ampersand)
|
||||||
|
* `[` (left bracket)
|
||||||
|
* `\\` (two backward slashes)
|
||||||
|
* `_` (underscore)
|
||||||
|
* `^` (caret)
|
||||||
|
|
||||||
|
These `a`, `ctrl-a`, `X`, or `ctrl-\\` values are all examples of valid key
|
||||||
|
sequences. To configure a different configuration default key sequence for all
|
||||||
|
containers, see [**Configuration file** section](cli.md#configuration-files).
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
|
|
||||||
$ docker run -d --name topdemo ubuntu /usr/bin/top -b
|
$ docker run -d --name topdemo ubuntu /usr/bin/top -b
|
||||||
|
|
|
@ -101,7 +101,26 @@ The property `psFormat` specifies the default format for `docker ps` output.
|
||||||
When the `--format` flag is not provided with the `docker ps` command,
|
When the `--format` flag is not provided with the `docker ps` command,
|
||||||
Docker's client uses this property. If this property is not set, the client
|
Docker's client uses this property. If this property is not set, the client
|
||||||
falls back to the default table format. For a list of supported formatting
|
falls back to the default table format. For a list of supported formatting
|
||||||
directives, see the [**Formatting** section in the `docker ps` documentation](ps.md)
|
directives, see the
|
||||||
|
[**Formatting** section in the `docker ps` documentation](ps.md)
|
||||||
|
|
||||||
|
Once attached to a container, users detach from it and leave it running using
|
||||||
|
the using `CTRL-p CTRL-q` key sequence. This detach key sequence is customizable
|
||||||
|
using the `detachKeys` property. Specify a `<sequence>` value for the
|
||||||
|
property. The format of the `<sequence>` is either a letter [a-Z], or the `ctrl-`
|
||||||
|
combined with any of the following:
|
||||||
|
|
||||||
|
* `a-z` (a single lowercase alpha character )
|
||||||
|
* `@` (ampersand)
|
||||||
|
* `[` (left bracket)
|
||||||
|
* `\\` (two backward slashes)
|
||||||
|
* `_` (underscore)
|
||||||
|
* `^` (caret)
|
||||||
|
|
||||||
|
Your customization applies to all containers started in with your Docker client.
|
||||||
|
Users can override your custom or the default key sequence on a per-container
|
||||||
|
basis. To do this, the user specifies the `--detach-keys` flag with the `docker
|
||||||
|
attach`, `docker exec`, `docker run` or `docker start` command.
|
||||||
|
|
||||||
The property `imagesFormat` specifies the default format for `docker images` output.
|
The property `imagesFormat` specifies the default format for `docker images` output.
|
||||||
When the `--format` flag is not provided with the `docker images` command,
|
When the `--format` flag is not provided with the `docker images` command,
|
||||||
|
@ -115,8 +134,9 @@ Following is a sample `config.json` file:
|
||||||
"HttpHeaders": {
|
"HttpHeaders": {
|
||||||
"MyHeader": "MyValue"
|
"MyHeader": "MyValue"
|
||||||
},
|
},
|
||||||
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}"
|
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}",
|
||||||
"imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}"
|
"imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}",
|
||||||
|
"detachKeys": "ctrl-e,e"
|
||||||
}
|
}
|
||||||
|
|
||||||
### Notary
|
### Notary
|
||||||
|
|
|
@ -15,6 +15,7 @@ parent = "smn_cli"
|
||||||
Run a command in a running container
|
Run a command in a running container
|
||||||
|
|
||||||
-d, --detach Detached mode: run command in the background
|
-d, --detach Detached mode: run command in the background
|
||||||
|
--detach-keys Specify the escape key sequence used to detach a container
|
||||||
--help Print usage
|
--help Print usage
|
||||||
-i, --interactive Keep STDIN open even if not attached
|
-i, --interactive Keep STDIN open even if not attached
|
||||||
--privileged Give extended Linux capabilities to the command
|
--privileged Give extended Linux capabilities to the command
|
||||||
|
|
|
@ -28,6 +28,7 @@ parent = "smn_cli"
|
||||||
--cpuset-cpus="" CPUs in which to allow execution (0-3, 0,1)
|
--cpuset-cpus="" CPUs in which to allow execution (0-3, 0,1)
|
||||||
--cpuset-mems="" Memory nodes (MEMs) in which to allow execution (0-3, 0,1)
|
--cpuset-mems="" Memory nodes (MEMs) in which to allow execution (0-3, 0,1)
|
||||||
-d, --detach Run container in background and print container ID
|
-d, --detach Run container in background and print container ID
|
||||||
|
--detach-keys Specify the escape key sequence used to detach a container
|
||||||
--device=[] Add a host device to the container
|
--device=[] Add a host device to the container
|
||||||
--device-read-bps=[] Limit read rate (bytes per second) from a device (e.g., --device-read-bps=/dev/sda:1mb)
|
--device-read-bps=[] Limit read rate (bytes per second) from a device (e.g., --device-read-bps=/dev/sda:1mb)
|
||||||
--device-read-iops=[] Limit read rate (IO per second) from a device (e.g., --device-read-iops=/dev/sda:1000)
|
--device-read-iops=[] Limit read rate (IO per second) from a device (e.g., --device-read-iops=/dev/sda:1000)
|
||||||
|
|
|
@ -15,5 +15,6 @@ parent = "smn_cli"
|
||||||
Start one or more containers
|
Start one or more containers
|
||||||
|
|
||||||
-a, --attach Attach STDOUT/STDERR and forward signals
|
-a, --attach Attach STDOUT/STDERR and forward signals
|
||||||
|
--detach-keys Specify the escape key sequence used to detach a container
|
||||||
--help Print usage
|
--help Print usage
|
||||||
-i, --interactive Attach container's STDIN
|
-i, --interactive Attach container's STDIN
|
||||||
|
|
|
@ -6,6 +6,7 @@ docker-attach - Attach to a running container
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
**docker attach**
|
**docker attach**
|
||||||
|
[**--detach-keys**[=*[]*]]
|
||||||
[**--help**]
|
[**--help**]
|
||||||
[**--no-stdin**]
|
[**--no-stdin**]
|
||||||
[**--sig-proxy**[=*true*]]
|
[**--sig-proxy**[=*true*]]
|
||||||
|
@ -18,15 +19,19 @@ interactively. You can attach to the same contained process multiple times
|
||||||
simultaneously, screen sharing style, or quickly view the progress of your
|
simultaneously, screen sharing style, or quickly view the progress of your
|
||||||
detached process.
|
detached process.
|
||||||
|
|
||||||
You can detach from the container (and leave it running) with `CTRL-p CTRL-q`
|
To stop a container, use `CTRL-c`. This key sequence sends `SIGKILL` to the
|
||||||
(for a quiet exit) or `CTRL-c` which will send a `SIGKILL` to the container.
|
container. You can detach from the container (and leave it running) using a
|
||||||
When you are attached to a container, and exit its main process, the process's
|
configurable key sequence. The default sequence is `CTRL-p CTRL-q`. You
|
||||||
exit code will be returned to the client.
|
configure the key sequence using the **--detach-keys** option or a configuration
|
||||||
|
file. See **config-json(5)** for documentation on using a configuration file.
|
||||||
|
|
||||||
It is forbidden to redirect the standard input of a `docker attach` command while
|
It is forbidden to redirect the standard input of a `docker attach` command while
|
||||||
attaching to a tty-enabled container (i.e.: launched with `-t`).
|
attaching to a tty-enabled container (i.e.: launched with `-t`).
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
**--detach-keys**=""
|
||||||
|
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
|
||||||
|
|
||||||
**--help**
|
**--help**
|
||||||
Print usage statement
|
Print usage statement
|
||||||
|
|
||||||
|
@ -36,6 +41,30 @@ attaching to a tty-enabled container (i.e.: launched with `-t`).
|
||||||
**--sig-proxy**=*true*|*false*
|
**--sig-proxy**=*true*|*false*
|
||||||
Proxy all received signals to the process (non-TTY mode only). SIGCHLD, SIGKILL, and SIGSTOP are not proxied. The default is *true*.
|
Proxy all received signals to the process (non-TTY mode only). SIGCHLD, SIGKILL, and SIGSTOP are not proxied. The default is *true*.
|
||||||
|
|
||||||
|
# Override the detach sequence
|
||||||
|
|
||||||
|
If you want, you can configure a override the Docker key sequence for detach.
|
||||||
|
This is is useful if the Docker default sequence conflicts with key squence you
|
||||||
|
use for other applications. There are two ways to defines a your own detach key
|
||||||
|
sequence, as a per-container override or as a configuration property on your
|
||||||
|
entire configuration.
|
||||||
|
|
||||||
|
To override the sequence for an individual container, use the
|
||||||
|
`--detach-keys="<sequence>"` flag with the `docker attach` command. The format of
|
||||||
|
the `<sequence>` is either a letter [a-Z], or the `ctrl-` combined with any of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
* `a-z` (a single lowercase alpha character )
|
||||||
|
* `@` (ampersand)
|
||||||
|
* `[` (left bracket)
|
||||||
|
* `\\` (two backward slashes)
|
||||||
|
* `_` (underscore)
|
||||||
|
* `^` (caret)
|
||||||
|
|
||||||
|
These `a`, `ctrl-a`, `X`, or `ctrl-\\` values are all examples of valid key
|
||||||
|
sequences. To configure a different configuration default key sequence for all
|
||||||
|
containers, see **docker(1)**.
|
||||||
|
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
|
|
||||||
## Attaching to a container
|
## Attaching to a container
|
||||||
|
|
|
@ -7,6 +7,7 @@ docker-exec - Run a command in a running container
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
**docker exec**
|
**docker exec**
|
||||||
[**-d**|**--detach**]
|
[**-d**|**--detach**]
|
||||||
|
[**--detach-keys**[=*[]*]]
|
||||||
[**--help**]
|
[**--help**]
|
||||||
[**-i**|**--interactive**]
|
[**-i**|**--interactive**]
|
||||||
[**--privileged**]
|
[**--privileged**]
|
||||||
|
@ -26,7 +27,10 @@ container is unpaused, and then run
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
**-d**, **--detach**=*true*|*false*
|
**-d**, **--detach**=*true*|*false*
|
||||||
Detached mode: run command in the background. The default is *false*.
|
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
|
||||||
|
|
||||||
|
**--detach-keys**=""
|
||||||
|
Define the key sequence which detaches the container.
|
||||||
|
|
||||||
**--help**
|
**--help**
|
||||||
Print usage statement
|
Print usage statement
|
||||||
|
|
|
@ -20,6 +20,7 @@ docker-run - Run a command in a new container
|
||||||
[**--cpuset-cpus**[=*CPUSET-CPUS*]]
|
[**--cpuset-cpus**[=*CPUSET-CPUS*]]
|
||||||
[**--cpuset-mems**[=*CPUSET-MEMS*]]
|
[**--cpuset-mems**[=*CPUSET-MEMS*]]
|
||||||
[**-d**|**--detach**]
|
[**-d**|**--detach**]
|
||||||
|
[**--detach-keys**[=*[]*]]
|
||||||
[**--device**[=*[]*]]
|
[**--device**[=*[]*]]
|
||||||
[**--device-read-bps**[=*[]*]]
|
[**--device-read-bps**[=*[]*]]
|
||||||
[**--device-read-iops**[=*[]*]]
|
[**--device-read-iops**[=*[]*]]
|
||||||
|
@ -190,8 +191,13 @@ the other shell to view a list of the running containers. You can reattach to a
|
||||||
detached container with **docker attach**. If you choose to run a container in
|
detached container with **docker attach**. If you choose to run a container in
|
||||||
the detached mode, then you cannot use the **-rm** option.
|
the detached mode, then you cannot use the **-rm** option.
|
||||||
|
|
||||||
When attached in the tty mode, you can detach from a running container without
|
When attached in the tty mode, you can detach from the container (and leave it
|
||||||
stopping the process by pressing the keys CTRL-P CTRL-Q.
|
running) using a configurable key sequence. The default sequence is `CTRL-p CTRL-q`.
|
||||||
|
You configure the key sequence using the **--detach-keys** option or a configuration file.
|
||||||
|
See **config-json(5)** for documentation on using a configuration file.
|
||||||
|
|
||||||
|
**--detach-keys**=""
|
||||||
|
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
|
||||||
|
|
||||||
**--device**=[]
|
**--device**=[]
|
||||||
Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)
|
Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)
|
||||||
|
|
|
@ -7,6 +7,7 @@ docker-start - Start one or more containers
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
**docker start**
|
**docker start**
|
||||||
[**-a**|**--attach**]
|
[**-a**|**--attach**]
|
||||||
|
[**--detach-keys**[=*[]*]]
|
||||||
[**--help**]
|
[**--help**]
|
||||||
[**-i**|**--interactive**]
|
[**-i**|**--interactive**]
|
||||||
CONTAINER [CONTAINER...]
|
CONTAINER [CONTAINER...]
|
||||||
|
@ -17,7 +18,11 @@ Start one or more containers.
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
**-a**, **--attach**=*true*|*false*
|
**-a**, **--attach**=*true*|*false*
|
||||||
Attach container's STDOUT and STDERR and forward all signals to the process. The default is *false*.
|
Attach container's STDOUT and STDERR and forward all signals to the
|
||||||
|
process. The default is *false*.
|
||||||
|
|
||||||
|
**--detach-keys**=""
|
||||||
|
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
|
||||||
|
|
||||||
**--help**
|
**--help**
|
||||||
Print usage statement
|
Print usage statement
|
||||||
|
|
|
@ -223,6 +223,7 @@ inside it)
|
||||||
Block until a container stops, then print its exit code
|
Block until a container stops, then print its exit code
|
||||||
See **docker-wait(1)** for full documentation on the **wait** command.
|
See **docker-wait(1)** for full documentation on the **wait** command.
|
||||||
|
|
||||||
|
|
||||||
# EXEC DRIVER OPTIONS
|
# EXEC DRIVER OPTIONS
|
||||||
|
|
||||||
Use the **--exec-opt** flags to specify options to the execution driver. The only
|
Use the **--exec-opt** flags to specify options to the execution driver. The only
|
||||||
|
|
Loading…
Reference in New Issue