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, 1268🔥, 0💬
Popular Posts:
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
What Azure AD App Registration Manifest? Azure AD App Registration Manifest is JSON file that contai...
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...
How to pull NVIDIA CUDA Docker Image with the "docker image pull nvidia/cuda" command? If you are ru...
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...