How do I attach VisualVM to a simple Java process running in a Docker container

后端 未结 6 1773
礼貌的吻别
礼貌的吻别 2020-12-12 14:35

Actually I wanted a solution working for JEE containers, specifically for Glassfish, but after I tried many combinations of settings and did not succeed, I reduced the setup

6条回答
  •  萌比男神i
    2020-12-12 14:52

    I followed an other SO response to a similar question and it worked.

    I started my Java process inside the container by adding those JVM params:

    -Dcom.sun.management.jmxremote.port= \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.rmi.port= \
    -Djava.rmi.server.hostname=$HOST_HOSTNAME
    

    and started the Docker container specifying -e HOST_HOSTNAME=$HOSTNAME -p to the docker run command.

    Then I've been able to access to this remote Java app from my local JVisualVm by adding a remote JMX connection ("File" > "Add a JMX Connection...") and specifying : in the "Connection" input, and checking "Do not require SSL connection".

提交回复
热议问题