What is Docker attach?

When containers are run with the interactive option, you can connect to the container and enter commands as if you are on the terminal:

$ docker run -itd --name busybox busybox
dcaecf3335f9142e8c70a2ae05a386395b49d610be345b3a12d2961fccab1478

$ docker attach busybox
/ # echo hello world
hello world

The attach option also allows multiple connections to view the same container and see what each is typing.

Lastly, while connected to a container with the tty option (-t), you can type ControlP ControlQ to detach from that container and leave it running in the background. You can then attach to that container again in the future.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)