Tools, FAQ, Tutorials:
"docker container attach" - Attach Console
How to attach the hosting console to the TTY terminal of the default running command on a container using the "docker container attach" command?
✍: FYIcenter.com
If the default running command has a TTY terminal for STDIN and STDOUT,
you can attach the hosting console to interact with the running command
using the "docker container attach" command.
1. Create a new container with a TTY terminal in interactive mode:
fyicenter$ docker container create --name java --tty --interactive openjdk
2. Start the container with the console attached to the TTY terminal and interact with the default command.
fyicenter$ docker container start --attach --interactive java java.util.prefs.FileSystemPreferences$1 run INFO: Created user preferences directory. | Welcome to JShell -- Version 12.0.1 | For an introduction type: /help intro jshell> 1+2; fyicenter$1 ==> 3 jshell>
3. Keep this console running and create another console on the hosting system. Then attach the second console to the TTY terminal of the container:
fyicenter$ docker container attach java jshell> 3+4; fyicenter$2 ==> 7
4. Go back to the first console, you see same input and output displayed
jshell> 3+4; fyicenter$2 ==> 7
4. If you run a "jshell" statement on the first console, you will the same input and output on the second console too.
As you can see, we are able to create a container that runs "jshell" as the default command and attach two consoles to command's TTY terminal.
⇒ "Ctrl-p Ctrl-q" - detach Console
⇐ "docker container start --interactive" - Interact with Container
2021-10-10, 1374🔥, 0💬
Popular Posts:
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...
How To Submit Values without Using a Form in PHP? If you know the values you want to submit, you can...
Where to get a real Atom XML example? You can follow this tutorial to get a real Atom XML example: 1...
How to install "The Windows SDK version 8.1"? I need to build my Visual Studio C++ applications. If ...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...