How to connect with JMX from host to Docker container in Docker machine?

前端 未结 2 1593
醉酒成梦
醉酒成梦 2021-01-18 04:23

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

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-18 04:40

    If anyone has problems with it. I have started the java process in the docker container with the following parameters:

    -Dcom.sun.management.jmxremote 
    -Dcom.sun.management.jmxremote.port=9876 
    -Dcom.sun.management.jmxremote.rmi.port=9876 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Djava.rmi.server.hostname=
    

    The important part is to set the name of the docker container. EXPOSE the port in the container 9876. I have also setup an ssh connection and forwarded 9876 to the localhost.

    The following goes to your SSH config:

    LocalForward 127.0.0.1:9876 127.0.0.1:9876
    

    Also I have setup /etc/hosts on the local machine

    127.0.0.1 
    

    Now connect your console to "name of the docker container"

提交回复
热议问题