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, 1176🔥, 0💬
Popular Posts:
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
How to add an API to an API product for internal testing on the Publisher Portal of an Azure API Man...
How to use the "forward-request" Policy Statement to call the backend service for an Azure API servi...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
What Happens If One Row Has Missing Columns? What happens if one row has missing columns? Most brows...