"docker container exec --tty --interactive" - Attach to Container
How to attach console to a Running Container using the "docker container exec" command? I want to get a shell TTY terminal on the container.
To attach a TTY terminal console to a Running Container, you can execute the /bin/sh command on the container with "--tty and "--interactive" options.
1. Check the container status to make it is still running.
$ docker container list --latest CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES a4570be81d29 alpine "sleep 36000" 8 minutes ago Up 8 minutes 3rd_alpine
2. Send the "/bin/sh" command to the container and stay attached as the console.
$ docker container exec --tty --interactive 3rd_alpine /bin/sh / # ps -ef PID USER TIME COMMAND 1 root 0:00 sleep 36000 31 root 0:00 /bin/sh 41 root 0:00 ps -ef
3. End the shell TTY terminal session.
/ # exit $
As you can see, with the Alpine container running the "sleep" command in the background, we can a TTY shell terminal to run any Alpine Linux command.
Basically, we have a baby virtual Alpine Linux system running on the Docker Engine.
2018-12-28, 369👍, 0💬
What is EPUB 2.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 2.0 Metadata "dc:publisher" ...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...
How to create Hello-3.1.epub with WinRAR? I have all required files to create Hello-3.1.epub. To cre...
What Is HTML? HTML (HyperText Markup Language) is the standard markup language for creating Web page...
What Is the 2017 Version of Azure API Management Service? The 2017 Version of Azure API Management a...