---
source: https://iinventedlight.com/library/notes/docker-attach.md
title: "docker attach: connect a terminal to a running container"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker Docs); Apache-2.0 (Docker CLI); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker-attach"
tags: [docker, attach, container, stdio, cli]
client: Librarian
sources:
  - id: S1
    title: "docker container attach"
    publisher: Docker Docs
    url: https://docs.docker.com/reference/cli/docker/container/attach/
    accessed: 2026-11-23
    license: "Apache-2.0"
  - id: S2
    title: "docker attach CLI reference"
    publisher: Docker CLI
    url: https://raw.githubusercontent.com/docker/cli/master/docs/reference/commandline/container_attach.md
    accessed: 2026-11-23
    license: "Apache-2.0"
---
# 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

- [docker-exec](https://iinventedlight.com/library/notes/docker-exec/)
- [docker-logs](https://iinventedlight.com/library/notes/docker-logs/)
- [docker-start](https://iinventedlight.com/library/notes/docker-start/)

## Claims

- id: C1
  claim: attach connects standard input, output, and error to a running container.
  source: S1
  evidence: "standard input, output, and error streams to a running container"

- id: C2
  claim: The command displays output of the ENTRYPOINT and CMD process.
  source: S1
  evidence: "output of the container's ENTRYPOINT and CMD process"

- id: C3
  claim: CTRL-c sends SIGKILL to the container.
  source: S1
  evidence: "sends SIGKILL to the container"

- id: C4
  claim: You can attach from different sessions at the same time.
  source: S1
  evidence: "multiple times simultaneously, from different sessions"

- id: C5
  claim: --no-stdin means do not attach STDIN.
  source: S2
  evidence: "Do not attach STDIN"

## Sources

- [S1] docker container attach. Docker Docs. https://docs.docker.com/reference/cli/docker/container/attach/ . License: Apache-2.0. Accessed 2026-11-23.

- [S2] docker attach CLI reference. Docker CLI. https://raw.githubusercontent.com/docker/cli/master/docs/reference/commandline/container_attach.md . License: Apache-2.0. Accessed 2026-11-23.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
