.nh .TH "DOCKER" "1" "Feb 2026" "Docker Community" "Docker User Manuals" .SH NAME docker-container-attach - Attach local standard input, output, and error streams to a running container .SH SYNOPSIS \fBdocker container attach [OPTIONS] CONTAINER\fP .SH DESCRIPTION The \fBdocker attach\fP 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 detached process. .PP To stop a container, use \fBCTRL-c\fR\&. This key sequence sends \fBSIGKILL\fP to the container. You can detach from the container (and leave it running) using a configurable key sequence. The default sequence is \fBCTRL-p CTRL-q\fR\&. You configure the key sequence using the \fB--detach-keys\fP option or a configuration file. See \fBconfig-json(5)\fP for documentation on using a configuration file. .PP It is forbidden to redirect the standard input of a \fBdocker attach\fP command while attaching to a TTY-enabled container (i.e., launched with \fB-i\fR and \fB-t\fR). .SH EXAMPLES .SH Attaching to a container In this example the top command is run inside a container from an ubuntu image, in detached mode, then attaches to it, and then terminates the container with \fBCTRL-c\fR: .EX $ docker run -d --name topdemo alpine top -b $ docker attach topdemo Mem: 2395856K used, 5638884K free, 2328K shrd, 61904K buff, 1524264K cached CPU: 0% usr 0% sys 0% nic 99% idle 0% io 0% irq 0% sirq Load average: 0.15 0.06 0.01 1/567 6 PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND 1 0 root R 1700 0% 3 0% top -b ^C .EE .SH Override the detach sequence Use the \fB--detach-keys\fP option to override the Docker key sequence for detach. This is useful if the Docker default sequence conflicts with key sequence you use for other applications. There are two ways to define your own detach key sequence, as a per-container override or as a configuration property on your entire configuration. .PP To override the sequence for an individual container, use the \fB--detach-keys\fP=\fIkey\fP flag with the \fBdocker attach\fP command. The format of the \fIkey\fP is either a letter [a-Z], or the \fBctrl\fP-\fIvalue\fP, where \fIvalue\fP is one of the following: .IP \(bu 2 \fBa-z\fP (a single lowercase alpha character ) .IP \(bu 2 \fB@\fP (at sign) .IP \(bu 2 \fB[\fP (left bracket) .IP \(bu 2 *\fI\\\\*\fP (two backward slashes) .IP \(bu 2 \fB_\fP (underscore) .IP \(bu 2 \fB^\fP (caret) .PP These \fBa\fP, \fBctrl-a\fP, \fBX\fP, or *\fIctrl-\\*\fP values are all examples of valid key sequences. To configure a different configuration default key sequence for all containers, see \fBdocker(1)\fP\&. .SH OPTIONS \fB--detach-keys\fP="" Override the key sequence for detaching a container .PP \fB--no-stdin\fP[=false] Do not attach STDIN .PP \fB--sig-proxy\fP[=true] Proxy all received signals to the process .SH SEE ALSO \fBdocker-container(1)\fP