2014-04-16 14:07:55 -04:00
|
|
|
% DOCKER(1) Docker User Manuals
|
2014-06-30 22:58:04 -04:00
|
|
|
% Docker Community
|
|
|
|
% JUNE 2014
|
2014-04-16 14:07:55 -04:00
|
|
|
# NAME
|
|
|
|
docker-attach - Attach to a running container
|
|
|
|
|
|
|
|
# SYNOPSIS
|
2014-06-30 22:58:04 -04:00
|
|
|
**docker attach**
|
2014-10-15 17:14:12 -04:00
|
|
|
[**--help**]/
|
2014-06-30 22:58:04 -04:00
|
|
|
[**--no-stdin**[=*false*]]
|
|
|
|
[**--sig-proxy**[=*true*]]
|
2014-11-27 23:21:55 -05:00
|
|
|
CONTAINER
|
2014-04-16 14:07:55 -04:00
|
|
|
|
|
|
|
# DESCRIPTION
|
|
|
|
If you **docker run** a container in detached mode (**-d**), you can reattach to
|
2014-05-27 13:56:11 -04:00
|
|
|
the detached container with **docker attach** using the container's ID or name.
|
2014-04-16 14:07:55 -04:00
|
|
|
|
2014-08-14 08:20:38 -04:00
|
|
|
You can detach from the container again (and leave it running) with `CTRL-p
|
2014-05-27 13:56:11 -04:00
|
|
|
CTRL-q` (for a quiet exit), or `CTRL-c` which will send a SIGKILL to the
|
|
|
|
container, or `CTRL-\` to get a stacktrace of the Docker client when it quits.
|
2014-04-17 11:36:58 -04:00
|
|
|
When you detach from a container the exit code will be returned to
|
2014-04-16 14:07:55 -04:00
|
|
|
the client.
|
|
|
|
|
2014-12-05 19:50:56 -05: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-04-16 14:07:55 -04:00
|
|
|
# OPTIONS
|
2014-10-15 17:14:12 -04:00
|
|
|
**--help**
|
|
|
|
Print usage statement
|
|
|
|
|
2014-04-16 14:07:55 -04:00
|
|
|
**--no-stdin**=*true*|*false*
|
2014-06-30 22:58:04 -04:00
|
|
|
Do not attach STDIN. The default is *false*.
|
2014-04-16 14:07:55 -04:00
|
|
|
|
2014-06-30 22:58:04 -04:00
|
|
|
**--sig-proxy**=*true*|*false*
|
2014-11-13 04:40:45 -05: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 14:07:55 -04:00
|
|
|
|
|
|
|
# EXAMPLES
|
|
|
|
|
2014-04-17 11:36:58 -04:00
|
|
|
## Attaching to a container
|
2014-04-16 14:07:55 -04: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 11:36:58 -04:00
|
|
|
April 2014, Originally compiled by William Henry (whenry at redhat dot com)
|
2014-07-01 20:30:25 -04:00
|
|
|
based on docker.com source material and internal work.
|
2014-06-30 22:58:04 -04:00
|
|
|
June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
|