In this quick tutorial we will learn how to monitor a Docker Container image of WildFly with JConsole

The docker image of WildFly is available from Dockerhub with the name jboss/wildfly:latest. We will however need to extend this image to include the creation of a management user that is needed to attach remotely from JConsole. Also we need to expose remotely the server's address to allow reaching it remotely.

Create a file named Dockerfile with this content:

FROM jboss/wildfly:latest
 
RUN /opt/jboss/wildfly/bin/add-user.sh admin1234 Password1! --silent
 
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

We will at first build the new layers with:

$ docker build --tag=wildfly-admin .

This will take a while as you will need to download the Docker image (if you haven't it locally). Next you can run it as follows:

$ docker run -it -p 9990:9990 wildfly-admin

In the above command, we have tunneled port 9990, the management port, which needs to be reached by jconsole.

Let's check which IP Address has been assigned to the WildFly image, with a combination of 'docker ps' and 'docker inspect':

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
1913f9e6909d        wildfly-admin       "/opt/jboss/wildfly/b"   2 minutes ago       Up 2 minutes        8080/tcp, 0.0.0.0:9990->9990/tcp   jolly_davinci

$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' 1913f9e6909d0c7f3f5e37aaed1cb635ad113887b4c7b45c12e087e670ba447a 
172.17.0.2

Now you need to launch WildFly version of jconsole, which is available in the JBOSS_HOME/bin folder of the application server

Please note that you will need using the same local version of WildFly to connect to the image in the container. This is needed since the wrapper script of jconsole will add some wildfly libraries that must be of the same version as wildFly's docker image.


You can launch JConsole using JMX over remoting as protocol on port 9990. Here is the URI to be used for the Connection: service:jmx:remote+http://172.17.0.2:9990

Also you need to include in the Username and Password the credentials for your User as indicated in the following picture:

jconsole monitoring wildfly

You will see that in a few seconds you will reach JConsole's main page:

jconsole monitoring wildfly

That's it! in the next tutorial we will see how to connect from JVisualVm to a Docker image of WildFly. Stay tuned!

0
0
0
s2smodern

Related articles available on mastertheboss.com

How to monitor JBoss CPU usage ?

  JBoss AS 7 users and WildFly can use JConsole in order to moni

How to monitor jboss graphically ?

  You’ve been using the JMX Console to access yourMBeans. In thi

How to monitor JBoss with snapshots?

  JBoss gives you the ability to capture data not only in real t

JBoss Alarm configuration

An Alarm indicates that an event (generally an error) has happene

Monitoring JBoss EJB Container

In this article we will show how easily you can write an Intercep

Monitor JBoss AS with Jolokia

Jolokia is a cool monitoring solution for accessing JMX MBeans re

W

i

l

d

F

l

y

 

c

h

e

a

t

s

h

e

e

t