Jakub
Jakub

Reputation: 2141

Enable JMX in Tomcat docker container

I'm trying to enable JMX on tomcat docker image using docker-compose.yml but I'm still getting error that VisualVM cannot connect to the JMX.

  tomcat:
    image: tomcat:8.0-jre8
    environment:
     CATALINA_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
    ports:
     - "9000:9000"

Upvotes: 2

Views: 1199

Answers (1)

Christopher Schultz
Christopher Schultz

Reputation: 20862

JMX requires more than just a single port since RMI is also involved. Remote JMX is always a challenge with Tomcat, and using Docker basically makes this "remote" access.

Have a look at Tomcat's JMX Remote Lifecycle Listener to see the port numbers that can be set, and use that listener to set them. If you don't, the RMI server is basically free to use whatever ports it wants to use and you can't predict them.

Once you set those ports, give the port mapping to Docker and you should be good to go.

Upvotes: 1

Related Questions