Access to JMX inside a docker container with mapped ports

I am trying to access an application running inside a docker container using JMX.

This is similar to this question , and this solution works when the ports inside the docker image are mapped to the same ports outside the image. However, I sometimes want to map a port to another port.

I set these properties in a managed application.

-Dcom.sun.management.jmxremote.port=9832 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.rmi.port=9832 -Djava.rmi.server.hostname=192.168.99.100 -Djava.rmi.server.logCalls=true 

This works great when the docker container maps port 9832 to 9832. I can connect via JConsole or our own application. If instead the port maps to another port, then I cannot access the application from JConsole or our application.

I suspected that one or two port numbers should be an external port (just like java.rmi.server.hostname is an external address, not an internal one). However, it does not work with all four combinations of port numbers.

Two of these combinations do not produce any log output on the server. One (I forget that) produces this conclusion:

 Feb 09, 2016 10:35:54 PM org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl start INFO: AMQ221001: Apache ActiveMQ Artemis Message Broker version 1.1.0 [nodeID=7a6e038e-cf7d-11e5-b566-31dc437b2d1a] HTTP Server started at http://0.0.0.0:8161 Feb 09, 2016 10:36:06 PM sun.rmi.server.UnicastServerRef logCall FINER: RMI TCP Connection(1)-192.168.99.1: [192.168.99.1: sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)] Feb 09, 2016 10:36:08 PM sun.rmi.transport.Transport serviceCall FINE: RMI TCP Connection(1)-192.168.99.1: [192.168.99.1] exception: java.rmi.NoSuchObjectException: no such object in table at sun.rmi.transport.Transport.serviceCall(Transport.java:177) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Feb 09, 2016 10:40:24 PM sun.rmi.server.UnicastServerRef logCall FINER: RMI TCP Connection(2)-192.168.99.1: [192.168.99.1: sun.rmi.transport.DGCImpl[0:0:0, 2]: void clean(java.rmi.server.ObjID[], long, java.rmi.dgc.VMID, boolean)] 

Another produces this conclusion.

 HTTP Server started at http://0.0.0.0:8161 Feb 09, 2016 10:14:13 PM sun.rmi.server.UnicastServerRef logCall FINER: RMI TCP Connection(1)-192.168.99.1: [192.168.99.1: sun.management.jmxremote.SingleEntryRegistry[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)] Feb 09, 2016 10:14:17 PM sun.rmi.server.UnicastServerRef logCall FINER: RMI TCP Connection(1)-192.168.99.1: [192.168.99.1: sun.management.jmxremote.SingleEntryRegistry[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)] Feb 09, 2016 10:14:17 PM sun.rmi.server.UnicastServerRef logCall FINER: RMI TCP Connection(1)-192.168.99.1: [192.168.99.1: sun.management.jmxremote.SingleEntryRegistry[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)] 

Given these failures, I suspect that one or both of the port properties are used in such a way that they sometimes need to be an internal port and sometimes need to be an external port. This would mean that JMX access is not possible when the ports are mapped to another location.

I can access the mapped port via telnet 192.168.99.100 <mapped port> , so I know that the mapping works.

+5
source share

Source: https://habr.com/ru/post/1242659/


All Articles