Tools, FAQ, Tutorials:
"docker container exec --tty --interactive ... /bin/sh"
How to run a Shell session interactively on a Running Container using the "docker container exec -tty --interactive ... /bin/sh" command?
✍: FYIcenter.com
If the running container is based on a Linux system,
we can definitely run
a Shell session interactively on a Running Container using
the "docker container exec --tty --interactive ... /bin/sh" command as shown below.
1. Create a new container from the "openjdk" image and start it in interactive mode.
fyicenter$ docker container create --name java --tty --interactive openjdk fyicenter$ docker container start --attach --interactive java jshell> 1+2; fyicenter$1 ==> 3 jshell>
2. Run the "/bin/sh" command to start a Shell session with a TTY terminal in interactive mode.
fyicenter$ docker container exec java /bin/sh sh-4.2# pwd / sh-4.2# ls /bin [ grep reset alias groups rm arch gsettings rmdir awk gtar rmic base64 gunzip rmid basename gzexe rmiregistry bash gzip rpcgen bashbug head rpm bashbug-64 hostid rpm2cpio bg iconv rpmdb ca-legacy id rpmkeys sh-4.2# env JAVA_URL=https://download.java.net/java/GA/jdk12.0.1/69cfe15208a647... HOSTNAME=77b2863fe925 TERM=xterm OLDPWD=/sbin PATH=/usr/java/openjdk-12/bin:/usr/local/sbin:/usr/local/bin:/usr/s... PWD=/ JAVA_HOME=/usr/java/openjdk-12 JAVA_VERSION=12.0.1 JAVA_SHA256=151eb4ec00f82e5e951126f572dc9116104c884d97f91be14ec11ee... HOME=/root sh-4.2# /bin/bash bash-4.2# ... (Ctrl-C)
The output shows that we are able to start Shell session interactively on the container to explore the running environment of the container, if it is based on a Linux system.
This is very useful to troubleshoot any issue on the container.
⇒ "docker container inspect" - Inspect Container Configuration
⇐ "docker container exec ... ls -l" - Files on Container
2021-10-02, ∼1658🔥, 0💬
Popular Posts:
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...
How to use the "return-response" Policy statement to build the response from scratch for an Azure AP...
How To Pass Arrays By References? in PHP? Like normal variables, you can pass an array by reference ...
How to use "link" command tool to link objet files? If you have object files previously compiled by ...
How to install "The Windows SDK version 8.1"? I need to build my Visual Studio C++ applications. If ...