Docker attach: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 9: Line 9:
The attachment will succeed only if the target container was started in [[Docker_Concepts#Interactive_Mode|interactive mode]]:
The attachment will succeed only if the target container was started in [[Docker_Concepts#Interactive_Mode|interactive mode]]:


  docker run [-d] -i alpine ash
  docker run [-d] '''-I''' alpine ash


Then, the attachment can be performed with:
Then, the attachment can be performed with:

Revision as of 07:45, 3 May 2018

Internal

Overview

Attaches the invoking shell's stdin, stdout and stderr to the container specified as argument.

The attachment will succeed only if the target container was started in interactive mode:

docker run [-d] -I alpine ash

Then, the attachment can be performed with:

docker attach <container-id>

Starting the container in detached mode is optional, docker attach can attach to a non-detached container, too. In that case, two shells (the one from which docker run was executed and the one from which docker attach was executed) will be attached at the same time to the container.