When I have running Docker container directly at my host, it is possible to connect to it without any problems.
My host has network 192.168.1.0/24 and IP address of the host is 192.168.1.20. My Docker container has IP address 172.17.0.2. When I connect to 172.17.0.2:1099 from jconsole it works.
When I put this service into Docker machine, it is not possible to connect to it.
My Docker machine has IP 192.168.99.100 and container in it has IP address 172.17.0.2 but when I use jconsole to connect to 192.168.99.100:1099 it does not work.
To repeat it:
192.168.1.20 --- 172.17.0.2:1099 works
192.168.1.20 --- (192.168.99.100 --- 172.17.0.2:1099) and connecting to 192.168.99.100:1099 from my host does not work.
It is worth to say that I can access services containerized in Docker machine via external IP address of the Docker machine, e.g. this will work:
192.168.99.100 --- (192.168.99.100:8080 --- 172.17.0.2:8080)
But when I use JMX it just does not work.
It is Tomcat service. I have this in scripts which starts Tomcat instance:
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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…