Monitoring WildFly Container image – Part 1: JConsole

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/ admin1234 Password1! --silent
CMD ["/opt/jboss/wildfly/bin/", "-b", "", "-bmanagement", ""]

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,>9990/tcp   jolly_davinci

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

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+

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!