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, ∼1638🔥, 0💬
Popular Posts:
How to access URL template parameters from "context.Request.Matched Parameters"object in Azure API P...
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to lo...
What is the Azure AD v1.0 OpenID Metadata Document? Azure AD v1.0 OpenID Metadata Document is an onl...
FYIcenter.com Online Tools: FYIcenter JSON Validator and Formatter FYIcenter JSON to XML Converter F...
How to use the "set-variable" Policy Statement to create custom variables for an Azure API service o...