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, 1363🔥, 0💬
Popular Posts:
What is EPUB 3.0 Metadata "dcterms:modified" property? EPUB 3.0 Metadata "dcterms:modified" is a req...
What properties and functions are supported on requests.models.Response objects? "requests" module s...
Can Multiple Paragraphs Be Included in a List Item? Yes. You can include multiple paragraphs in a si...
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...
How to use the "@(...)" expression in Azure API Policy? The "@(...)" expression in Azure API Policy ...