Monitoring java Applications in docker through jmx

  docker, java

Add jmx parameters

ENV JAVA_OPTS="\
-Dcom.sun.management.jmxremote.rmi.port=9090 \
-Dcom.sun.management.jmxremote=true \
-Dcom.sun.management.jmxremote.port=9090 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Djava.rmi.server.hostname=192.168.99.100"
EXPOSE 8080
EXPOSE 9090
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.jar

Where ava.rmi.server.hostname is the address of doc.

jvisualvm

Local Command Line Typing jvisualvm Open

  • Add remote machine
    192.168.99.100

  • Add jmx connection
    192.168.99.100:9090

SSL connection is not required

View mbean

Add plug-in VisualVM-MBeans

doc