← All notes

docker attach: connect a terminal to a running container

Answer: docker attach connects your terminal's standard input, output, and error streams to a running container. It displays output of the container's ENTRYPOINT and CMD process. If the container was run with -i and -t, you can detach using Ctrl-p Ctrl-q and leave it running.

What attach does

Give docker attach a container ID or name to hook your terminal's standard input, output, and error, or any mix of the three, to a running container.

You can then view output or drive the process interactively, as though those commands were running directly in your terminal.

Only the ENTRYPOINT and CMD process output is shown. This can appear as if the attach command is hung when the process is not writing any output.

The same contained process can be attached from different sessions on the Docker host, multiple times simultaneously.

Signals, detach keys, and options

To stop a container, use Ctrl-c. That key sequence sends SIGKILL.

When --sig-proxy is true, the default, CTRL-c sends SIGINT instead.

If the container was run with -i and -t, detach with Ctrl-p Ctrl-q and leave it running.

Linux treats a PID 1 process inside a container specially: it ignores any signal that has the default action.

Options include --detach-keys to override the detach sequence, --no-stdin so STDIN is not attached, and --sig-proxy to forward received signals.

Do not redirect standard input of docker attach while the container is TTY-enabled with -i and -t.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker Docs, docker container attach; Docker CLI, docker attach CLI reference. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/docker/cli/master/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker Docs, docker container attach; Docker CLI, docker attach CLI reference. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/docker/cli/master/LICENSE). Copyright Docker, Inc.

Cite this

Permanent ID: iil:note:61hfskaj

iinventedlight. 2026. "docker attach: connect a terminal to a running container." iinventedlight Library, iil:note:61hfskaj, version of 2026-11-23. https://iinventedlight.com/library/notes/docker-attach/. License: CC-BY-4.0.

@misc{iil_note_61hfskaj,
  author = {{iinventedlight}},
  title = {{docker attach: connect a terminal to a running container}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/docker-attach/},
  note = {Permanent ID iil:note:61hfskaj. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-attach.md.