Docker tomcat with jmx

dockerjmxtomcat

I'm trying to create a docker image with tomcat and JMX activated.

So I clone this tomcat docker image https://github.com/tutumcloud/tutum-docker-tomcat.
I exposed the port 1099 and edited the run script as follow:

#!/bin/bash

if [ ! -f /.tomcat_admin_created ]; then
    /create_tomcat_admin_user.sh
fi

export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" 
exec ${CATALINA_HOME}/bin/catalina.sh run

At the moment I don't really consider security, I just trying to have a JMX available.

Next a build the image docker build -t <name> and run it docker run -d -p 8080:8080 -p 1099:1099 <name>

Container is correctly launched and port forward: 0.0.0.0:1099->1099/tcp, 0.0.0.0:8080->8080/tcp

And port is open telnet 192.168.59.103 1099. I use 192.168.59.103 because I'm on macos with boot2docker, and 192.168.59.103 is boot2docker ip.

But when I'm trying to connect to JMX via jconsole I get a timeout..

Best Answer

I found the solution..

I must declare -Djava.rmi.server.hostname=192.168.59.103

Related Topic