DevOps

WildFly Admin Console in a Docker image

WildFly Docker image binds application port (8080) to all network interfaces (using -b 0.0.0.0). If you want to view feature-rich lovely-looking web-based administration console, then management port (9990) needs to be bound to all network interfaces as well using the shown command:
 
 
 
 
 
 
 

docker run -P -d jboss/wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0

This is overriding the default command in Docker file, explicitly starting WildFly, and binding application and management port to all network interfaces.

The -P flag map any network ports inside the image it to a random high port from the range 49153 to 65535 on Docker host. Exact port can be verified by giving docker ps command as shown:

docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f21dba8846bc jboss/wildfly:latest "/opt/jboss/wildfly/ 10 minutes ago Up 4 minutes 0.0.0.0:49161->8080/tcp, 0.0.0.0:49162->9990/tcp desperate_sammet

In this case, port 8080 is mapped to 49161 and port 9990 is mapped to 49162. IP address of Docker containers can be verified using boot2docker ip command. The default web page and admin console can then be accessed on these ports.

Accessing WildFly Administration Console require a user in administration realm. This can be done by using an image which will create that user. And since a new image is created, the Dockerfile can also consume network interface binding to keep the actual command-line simple. The Dockerfile is pretty straight forward:

FROM jboss/wildfly:latest
 
RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#007 --silent
 
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

This image has already been pushed to Docker Hub and source file is at github.com/arun-gupta/docker-images/tree/master/wildfly-admin. So to have a WildFly image with Administration Console, just run the image as shown:

docker run -P -d arungupta/wildfly-admin
Unable to find image 'arungupta/wildfly-admin' locally
Pulling repository arungupta/wildfly-admin
db43099acb0f: Download complete
511136ea3c5a: Download complete
782cf93a8f16: Download complete
7d3f07f8de5f: Download complete
1ef0a50fe8b1: Download complete
20a1abe1d9bf: Download complete
cd5bb934bb67: Download complete
379edb00ab07: Download complete
4d37cbbfc67d: Download complete
2ea8562cac7c: Download complete
7759146eab1a: Download complete
b17a20d6f5f8: Download complete
e02bdb6c4ed5: Download complete
72d585299bb5: Download complete
90832e1f0bb9: Download complete
2c3484b42034: Download complete
38fad13dea25: Download complete
656878d9a6c6: Download complete
6510de96c354: Download complete
0cc86be8ac93: Download complete
bf17b0944e53: Download complete
Status: Downloaded newer image for arungupta/wildfly-admin:latest
b668945fec004bd2597b0e919fa12fb5bca36eb8e28bcc8872cf3321db666f10

Then checked the mapped ports as:

docker ps
CONTAINER ID        IMAGE                            COMMAND                CREATED             STATUS              PORTS                                              NAMES
b668945fec00        arungupta/wildfly-admin:latest   "/opt/jboss/wildfly/   5 minutes ago       Up 8 seconds        0.0.0.0:49165->8080/tcp, 0.0.0.0:49166->9990/tcp   mad_einstein

Application port is mapped to 49165 and management port is mapped to 49166. Access the admin console at http://192.168.59.103:49166/ which will then prompt for the username (“admin”) and the password (“Admin#007″).

techtip66-admin-console

If you don’t like random ports being assigned by Docker, then you can map them to specific ports as well using the following command:

docker run -p 8080:8080 -p 9990:9990 -d arungupta/wildfly-admin

In this case, application port 8080 is mapped to 8080 on Docker host and management port 9990 is mapped to 9990 on Docker host. So the admin console will then be accessible at http://192.168.59.103:9990/.

Reference: WildFly Admin Console in a Docker image from our JCG partner Arun Gupta at the Miles to go 2.0 … blog.

Arun Gupta

Arun is a technology enthusiast, avid runner, author of a best-selling book, globe trotter, a community guy, Java Champion, JavaOne Rockstar, JUG Leader, Minecraft Modder, Devoxx4Kids-er, and a Red Hatter.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button