Saturday, 9 May 2020

docker exec: Connect to the container

Step 1: Execute below command, that starts wildfly server and you can able to access the server at localhost port 1234.
docker run -d -p1234:8080 jboss/wildfly
$docker run -d -p1234:8080 jboss/wildfly
Unable to find image 'jboss/wildfly:latest' locally
latest: Pulling from jboss/wildfly
a02a4930cb5d: Pull complete 
b5ffff9dbcda: Pull complete 
36845d6d0218: Pull complete 
08619c8c88e2: Pull complete 
1779d505ac3a: Pull complete 
Digest: sha256:ae4545bc428d36fa77746f48c23f43f11158ea37723a6ec2b55d999b930bf0e4
Status: Downloaded newer image for jboss/wildfly:latest
bdc55593d441a1103c38658bab2133c1f50626eee86b944cf3a57f015e56e3d5

once the server started, open the URL 'http://localhost:1234/', you can able to see WildFly server home page.

Step 2: Get into the container using 'docker exec' command.

Execute the command 'docker ps -a' to see list of all (running, stopped) container.

$docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS                    NAMES
bdc55593d441        jboss/wildfly       "/opt/jboss/wildfly/…"   2 minutes ago       Up 2 minutes                   0.0.0.0:1234->8080/tcp   vigilant_mclaren

Execute the below command to get into the container.
docker exec -ti bdc55593d441 /bin/bash

'bdc55593d441' is container id.
$docker exec -ti bdc55593d441 /bin/bash
[jboss@bdc55593d441 ~]$ pwd
/opt/jboss
[jboss@bdc55593d441 ~]$ 
[jboss@bdc55593d441 ~]$ ls
wildfly
[jboss@bdc55593d441 ~]$ 
[jboss@bdc55593d441 ~]$ ls -l wildfly/
total 544
-rw-rw-r-- 1 jboss root  26530 Jun  7 17:39 LICENSE.txt
-rw-rw-r-- 1 jboss root   2221 Jun  7 17:39 README.txt
drwxrwxr-x 3 jboss root   4096 Jun  7 17:39 appclient
drwxrwxr-x 3 jboss root   4096 Jun 10 16:19 bin
-rw-rw-r-- 1 jboss root   2451 Jun  7 17:39 copyright.txt
drwxrwxr-x 6 jboss root   4096 Jun  7 17:39 docs
drwxrwxr-x 4 jboss root   4096 Jun  7 17:39 domain
-rw-rw-r-- 1 jboss root 489207 Jun  7 17:39 jboss-modules.jar
drwxrwxr-x 3 jboss root   4096 Jun  7 17:39 modules
drwxrwxr-x 1 jboss root   4096 Jun 19 05:34 standalone
drwxrwxr-x 2 jboss root   4096 Jun 10 16:19 welcome-content

Execute the command 'exit' to come out of the bash shell.



Previous                                                    Next                                                    Home

No comments:

Post a Comment