2014-04-16 18:07:55 +00:00
% DOCKER(1) Docker User Manuals
2014-07-01 02:58:04 +00:00
% Docker Community
% JUNE 2014
2014-04-16 18:07:55 +00:00
# NAME
docker-attach - Attach to a running container
# SYNOPSIS
2014-07-01 02:58:04 +00:00
**docker attach**
2016-01-03 22:03:39 +00:00
[**--detach-keys**[=*[]*]]
2015-10-13 15:12:30 +00:00
[**--help**]
2015-12-23 14:37:06 +00:00
[**--no-stdin**]
2014-07-01 02:58:04 +00:00
[**--sig-proxy**[=*true*]]
2014-11-28 04:21:55 +00:00
CONTAINER
2014-04-16 18:07:55 +00:00
# DESCRIPTION
2015-02-02 12:48:12 +00:00
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
interactively. You can attach to the same contained process multiple times
simultaneously, screen sharing style, or quickly view the progress of your
2015-09-30 20:11:36 +00:00
detached process.
2015-02-02 12:48:12 +00:00
2016-01-03 22:03:39 +00:00
To stop a container, use `CTRL-c` . This key sequence sends `SIGKILL` to the
container. You can detach from the container (and leave it 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.
2015-02-02 12:48:12 +00:00
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` ).
2014-12-06 00:50:56 +00:00
2014-04-16 18:07:55 +00:00
# OPTIONS
2016-01-03 22:03:39 +00:00
**--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 `_` .
2014-10-15 21:14:12 +00:00
**--help**
Print usage statement
2014-04-16 18:07:55 +00:00
**--no-stdin**=*true*|*false*
2014-07-01 02:58:04 +00:00
Do not attach STDIN. The default is *false* .
2014-04-16 18:07:55 +00:00
2014-07-01 02:58:04 +00:00
**--sig-proxy**=*true*|*false*
2014-11-13 09:40:45 +00:00
Proxy all received signals to the process (non-TTY mode only). SIGCHLD, SIGKILL, and SIGSTOP are not proxied. The default is *true* .
2014-04-16 18:07:55 +00:00
2016-01-03 22:03:39 +00:00
# Override the detach sequence
2016-05-08 01:36:10 +00:00
If you want, you can configure an override the Docker key sequence for detach.
2016-06-05 21:03:23 +00:00
This is useful if the Docker default sequence conflicts with key sequence you
2016-06-07 02:06:50 +00:00
use for other applications. There are two ways to define your own detach key
2016-01-03 22:03:39 +00:00
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 )
2016-02-05 21:47:57 +00:00
* `@` (at sign)
2016-01-03 22:03:39 +00:00
* `[` (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)** .
2014-04-16 18:07:55 +00:00
# EXAMPLES
2014-04-17 15:36:58 +00:00
## Attaching to a container
2014-04-16 18:07:55 +00:00
In this example the top command is run inside a container, from an image called
fedora, in detached mode. The ID from the container is passed into the **docker
attach** command:
# ID=$(sudo docker run -d fedora /usr/bin/top -b)
# sudo docker attach $ID
top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
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
Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
Swap: 786428k total, 0k used, 786428k free, 221740k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
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
Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
Swap: 786428k total, 0k used, 786428k free, 221776k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
# HISTORY
2014-04-17 15:36:58 +00:00
April 2014, Originally compiled by William Henry (whenry at redhat dot com)
2014-07-02 00:30:25 +00:00
based on docker.com source material and internal work.
2014-07-01 02:58:04 +00:00
June 2014, updated by Sven Dowideit < SvenDowideit @ home . org . au >