When I launch the Docker container directly on my host, I can connect to it without any problems.
My host has a network of 192.168.1.0/24, and the host IP address is 192.168.1.20. My Docker container has an IP address of 172.17.0.2. When I connect to 172.17.0.2:1099 from jconsole, it works.
When I put this service in a Docker machine, I cannot connect to it.
My Docker machine has an IP of 192.168.99.100, and the container in it has an IP address of 172.17.0.2, but when I use jconsole to connect to 192.168.99.100:1099, it does not work.
To repeat this:
192.168.1.20 --- 172.17.0.2:1099 works
192.168.1.20 --- (192.168.99.100 --- 172.17.0.2:1099) and the connection to 192.168.99.100:1099 from my host does not work.
It is worth saying that I can access the container services in the Docker machine through the external IP address of the Docker device, for example. this will work:
192.168.99.100 --- (192.168.99.100:8080 --- 172.17.0.2:8080)
But when I use JMX, it just doesn't work.
This is a Tomcat service. I have this in scripts that run an instance of Tomcat:
CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n \ -Dcom.sun.management.jmxremote.port=1099 \ -Dcom.sun.management.jmxremote.rmi.port=1099 \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false \ -Djava.rmi.server.hostname=IP address of Docker container