Tuesday, 4 June 2019

Docker: Getting into the container


Containers are good at running exactly one command. To get into the container, add 'bash' at the end of the command.

Example
docker run -it jboss/wildfly bash

Instead of running jboss/wildfly container, this command launch bash shell, which is pointing to wildfly container image.

$docker run -it jboss/wildfly bash
[jboss@ed446ef19d1c ~]$ ls
wildfly
[jboss@ed446ef19d1c ~]$ cd  wildfly/
[jboss@ed446ef19d1c wildfly]$ 
[jboss@ed446ef19d1c wildfly]$ ls
LICENSE.txt  README.txt  appclient  bin  copyright.txt  docs  domain  jboss-modules.jar  modules  standalone  welcome-content


Open other terminal and execute the command 'docker container ls -a' to see list of all the containers.

$docker container ls -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ed446ef19d1c        jboss/wildfly       "bash"              47 seconds ago      Up 46 seconds       8080/tcp            sleepy_antonelli

As you see the output 'jboss/wildfly' container is started and running the command 'bash'.

How to exit from interactive shell?

Execute the command ‘exit’ to come out of interactive shell.

[jboss@ed446ef19d1c wildfly]$ pwd
/opt/jboss/wildfly
[jboss@ed446ef19d1c wildfly]$ 
[jboss@ed446ef19d1c wildfly]$ exit
exit
$




Previous                                                 Next                                                 Home

No comments:

Post a Comment