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

后端 未结 6 1763
礼貌的吻别
礼貌的吻别 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条回答
  •  时光取名叫无心
    2020-12-12 14:53

    Thanks to all of you for routing me to the right direction. Finally I got it working in more complex config: Kubernetes via Docker Desktop under Windows 10 on local machine.

    My app's config:

    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false
    -Dcom.sun.management.jmxremote.port=30491
    -Dcom.sun.management.jmxremote.rmi.port=30491
    -Djava.rmi.server.hostname=localhost
    

    Pod's port:

    ports:
    - name: jmx
      containerPort: 30491
      protocol: TCP
    

    Service's port:

    ports:
    - name: jmx
      nodePort: 30491
      port: 9010
      protocol: TCP
      targetPort: jmx
    

提交回复
热议问题