DEV Community

kgoedert
kgoedert

Posted on

Monitoring Wildfly inside docker

To monitor a wildfly instance that is running inside a docker container, is not as simple as simply exposing the port and connecting to it. The first thing you are going to need is to download a wildfly copy of the same version you are running inside the container, on the host machine you are going to use.

On your docker file you are going to need to add a user to your container, that will be able to connect to the administration interface, and expose a port. Since you are going to create a user that can alter the server configurations, think carefully before putting this in a production environment. To do that add a line like this to your Dockerfile:

RUN /opt/jboss/wildfly/bin/add-user.sh adm Password1! --silent

EXPOSE 9990

The name of the user and passoword can be whatever you want. The name admin, is taken by wildfly already, so I used adm. And 9990 is the port you need to expose, and then map to.

Once you have your container built and running (don't forget to map the port), you need to know which is your container internal IP address. One way to check that is with the command:

docker inspect <container-id>

In the output shown, you are going to have something like this:

"IPAddress": "172.21.0.2",

Now, everything related to the container is ready.

JConsole

If you want to connect with JConsole, in the host machine where you downloaded wildlfy go to $WILDFLY_HOME/bin and execute:

./jconsole.sh

On the window that shows up, check Remote Process, in the box, you need something like service:jmx:remote+http://172.17.0.2:9990, where the IP address is the one from your docker container. And in the username and password boxes type whatever you configured on your Dockerfile. Then, connect.

VisualVM

If you want to use VisualVM, first you need to install it:

sudo apt-get install visualvm

All the first part of configuring the container, is exactly the same. What is different here is that you need to add wildfly client API to visualvm classpath, so it can connect.

To do that, you run visualvm like this:

visualvm --cp:a $WILDFLY_HOME/bin/client/jboss-client.jar

Then, add a remote host and a JMX connection, using the same parameters used for JConsole.

Top comments (0)