linux - Monitor java application inside docker using JConsole -
i'm trying monitor java app, running inside docker container using jconsole, getting error:
connection failed: error during jrmp connection establishment; nested exception java.net.socketexception;
i'm using next docker params this guide (also used diff flags comments, like: djava.rmi.server.hostname=10.16.114.98 + --net=host, )
docker run -p 8080:8080 -p 9010:9010 --rm -e java_opts="-dcom.sun.management.jmxremote -dcom.sun.management.jmxremote.port=9010 -dcom.sun.management.jmxremote.local.only=false -dcom.sun.management.jmxremote.authenticate=false -dcom.sun.management.jmxremote.rmi.port=9010 -dcom.sun.management.jmxremote.ssl=false" gateway
os: red hat 7
here output docker inspect
:
[ { "id": "06df0e186f49297e217bab77c9101926bc2333c429d4551a151a64159a82c942", "created": "2017-08-18t12:52:37.002174333z", "path": "/bin/sh", "args": [ "-c", "echo \"the application start in ${jhipster_sleep}s...\" \u0026\u0026 sleep ${jhipster_sleep} \u0026\u0026 java -djava.security.egd=file:/dev/./urandom -jar /app.war" ], "state": { "status": "running", "running": true, "paused": false, "restarting": false, "oomkilled": false, "dead": false, "pid": 22543, "exitcode": 0, "error": "", "startedat": "2017-08-18t12:52:38.539827439z", "finishedat": "0001-01-01t00:00:00z" }, "image": "760fc9348dddb4ef6a3a031e6c75d31645ac811ce17a27289e462f265d21d5e7", "resolvconfpath": "/var/lib/docker/containers/06df0e186f49297e217bab77c9101926bc2333c429d4551a151a64159a82c942/resolv.conf", "hostnamepath": "/var/lib/docker/containers/06df0e186f49297e217bab77c9101926bc2333c429d4551a151a64159a82c942/hostname", "hostspath": "/var/lib/docker/containers/06df0e186f49297e217bab77c9101926bc2333c429d4551a151a64159a82c942/hosts", "logpath": "/var/lib/docker/containers/06df0e186f49297e217bab77c9101926bc2333c429d4551a151a64159a82c942/06df0e186f49297e217bab77c9101926bc2333c429d4551a151a64159a82c942-json.log", "name": "/desperate_hugle", "restartcount": 0, "driver": "devicemapper", "execdriver": "native-0.2", "mountlabel": "", "processlabel": "", "apparmorprofile": "", "execids": null, "hostconfig": { "binds": null, "containeridfile": "", "lxcconf": [], "memory": 0, "memoryreservation": 0, "memoryswap": 0, "kernelmemory": 0, "cpushares": 0, "cpuperiod": 0, "cpusetcpus": "", "cpusetmems": "", "cpuquota": 0, "blkioweight": 0, "oomkilldisable": false, "memoryswappiness": -1, "privileged": false, "portbindings": { "8080/tcp": [ { "hostip": "", "hostport": "8080" } ], "9010/tcp": [ { "hostip": "", "hostport": "9010" } ] }, "links": null, "publishallports": false, "dns": [], "dnsoptions": [], "dnssearch": [], "extrahosts": null, "volumesfrom": null, "devices": [], "networkmode": "default", "ipcmode": "", "pidmode": "", "utsmode": "", "capadd": null, "capdrop": null, "groupadd": null, "restartpolicy": { "name": "no", "maximumretrycount": 0 }, "securityopt": null, "readonlyrootfs": false, "ulimits": null, "logconfig": { "type": "json-file", "config": {} }, "cgroupparent": "", "consolesize": [ 0, 0 ], "volumedriver": "" }, "graphdriver": { "name": "devicemapper", "data": { "deviceid": "574", "devicename": "docker-253:0-135637248-06df0e186f49297e217bab77c9101926bc2333c429d4551a151a64159a82c942", "devicesize": "107374182400" } }, "mounts": [ { "name": "42e8ebbf5846da5067567cab9a72e75931c1190b94a5d62169b9c2cf54e33138", "source": "/var/lib/docker/volumes/42e8ebbf5846da5067567cab9a72e75931c1190b94a5d62169b9c2cf54e33138/_data", "destination": "/tmp", "driver": "local", "mode": "", "rw": true } ], "config": { "hostname": "06df0e186f49", "domainname": "", "user": "", "attachstdin": false, "attachstdout": true, "attachstderr": true, "exposedports": { "5701/udp": {}, "8080/tcp": {}, "9010/tcp": {} }, "tty": false, "openstdin": false, "stdinonce": false, "env": [ "java_opts=-dcom.sun.management.jmxremote -dcom.sun.management.jmxremote.port=9010 -dcom.sun.management.jmxremote.local.only=false -dcom.sun.management.jmxremote.authenticate=false -dcom.sun.management.jmxremote.rmi.port=9010 -dcom.sun.management.jmxremote.ssl=false", "path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin", "lang=c.utf-8", "java_home=/usr/lib/jvm/java-1.8-openjdk/jre", "java_version=8u131", "java_alpine_version=8.131.11-r1", "jhipster_sleep=0" ], "cmd": [ "/bin/sh", "-c", "echo \"the application start in ${jhipster_sleep}s...\" \u0026\u0026 sleep ${jhipster_sleep} \u0026\u0026 java -djava.security.egd=file:/dev/./urandom -jar /app.war" ], "image": "gateway", "volumes": { "/tmp": {} }, "workingdir": "", "entrypoint": null, "onbuild": null, "labels": {}, "stopsignal": "sigterm" }, "networksettings": { "bridge": "", "sandboxid": "1a318dd2e3bffc03a0242b08ba4e8a6592f076f89f317da8ba825f2be7ca01d5", "hairpinmode": false, "linklocalipv6address": "", "linklocalipv6prefixlen": 0, "ports": { "5701/udp": null, "8080/tcp": [ { "hostip": "0.0.0.0", "hostport": "8080" } ], "9010/tcp": [ { "hostip": "0.0.0.0", "hostport": "9010" } ] }, "sandboxkey": "/var/run/docker/netns/1a318dd2e3bf", "secondaryipaddresses": null, "secondaryipv6addresses": null, "endpointid": "df67c23d6e56d645dfe6a8767598bacd35d86e1b29a4caf078fd4c0bc5a92784", "gateway": "172.17.0.1", "globalipv6address": "", "globalipv6prefixlen": 0, "ipaddress": "172.17.0.3", "ipprefixlen": 16, "ipv6gateway": "", "macaddress": "02:42:ac:11:00:03", "networks": { "bridge": { "endpointid": "df67c23d6e56d645dfe6a8767598bacd35d86e1b29a4caf078fd4c0bc5a92784", "gateway": "172.17.0.1", "ipaddress": "172.17.0.3", "ipprefixlen": 16, "ipv6gateway": "", "globalipv6address": "", "globalipv6prefixlen": 0, } } } } ]
the problem seems value of java.rmi.server.hostname property.
this needs hostname or ip address used jmx client connect jvm. if try connect using 127.0.0.1:9010 use -djava.rmi.server.hostname=127.0.0.1 on startup
Comments
Post a Comment