Reputation: 85
I would like to use visualvm to check threads running in the karaf which is in a docker container.
What I did:
Need help.
Upvotes: 2
Views: 1163
Reputation: 6853
The problem is the RMI protocol, that does not handle the scenario well where the host offering the RMI endpoint (the Docker host) is not the the host of the RMI server (the VM inside your Docker container).
The way I got it to work was to
export EXTRA_JAVA_OPTS=="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.rmi.port=$JMX_RMI_PORT -Dcom.sun.management.jmxremote.port=$JMX_REMOTE_PORT -Djava.rmi.server.hostname=$HOST_HOSTNAME"
I set the environment with docker-compose, but you can replace the environment variables with fixed values as long as you run only one container with the image on your host. I am using 1097 and 1098 for the RMI and REMOTE ports respectively. Two things are important here:
java.rmi.server.hostname
is the hostname or IP of your docker host, not the IP of the containerAssuming you are using the ports above, then connecting to
service:jmx:rmi:///jndi/rmi://<your_docker_host>:1098/jmxrmi
should now work.
I never got Karaf's JMX accecss control to work though.
Using JMXMP instead of RMI for JMX might make things easier, but it is not supported by Karaf out of the box.
Upvotes: 1