Reputation: 3345
I am trying to retrieve metrics from a java process that is running in a docker container. The process was started with the following command but trying to access it via jconsole as a test, results in 'connection failed' retry?
docker run -d --name=process-2-kafka --restart=always -p 22222:22222 -v
/var/local/Blogs_Services/ProcessKafaka/:/program -w /program openjdk:8
java
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=22222 -
Dcom.sun.management.jmxremote.ssl=false -
Dcom.sun.management.jmxremote.authenticate=false -jar testkafka.jar -
Dcom.sun.management.jmxremote.local.only=false –
Djava.rmi.server.hostname=192.www.xxx.yy –
Dcom.sun.management.jmxremote.rmi.port=22222
I added the rmi.port and server.hostname after searching the internet but still results in the same error. Does anyone have a solution to this?
Upvotes: 0
Views: 723
Reputation: 3363
JMX connections to containers are notoriously frustrating. Two things I would suggest to try:
Use a separate port for jmxremote.port
and jmxremote.rmi.port
(for example 22222 and 22223) and port forward both of these in docker
Set your java.rmi.server.hostname
to be a name, eg dockerhost
, and add dockerhost
and the IP address of the machine hosting the container to your hosts file on all of the machine running the docker container, the docker container itself, and the machine you are running jconsole on. Then when you try to JMX, use dockerhost
in the URL instead of an IP address.
These may not solve your problem, but fingers crossed, good luck!
Upvotes: 1