如何监控Docker中的java应用程序内存使用情况 [英] How to monitor java application memory usage in Docker

查看:648
本文介绍了如何监控Docker中的java应用程序内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Docker容器中的tomcat上运行java Web应用程序。

I run the java web application on tomcat in the Docker container.

有没有办法监视java应用程序的内存使用情况?我尝试用docker的进程ID使用 jconsole ,但它告诉我无效的进程标识

Is there any way to monitor the memory usage of the java application? I try to use jconsole with the process id of the docker, but it tells me Invalidate process id

我还在tomcat中启用JMX,但不知道如何绑定它。我可以使用本地的 visualvm 绑定主机,但找不到绑定到主机内部的docker的方法。

I also enable JMX in tomcat, but don't know how to bind to it. I can use visualvm from my local to bind the host machine, but can not find way to bind to the docker inner the host.

有没有什么好办法实现这一点?

Is there any good way to achieve this?

谢谢

推荐答案

要连接到运行在运行在 boot2docker 中的Docker容器的java进程,使用 visualvm 您可以尝试以下操作:

To connect to a java process running in a docker container running in boot2docker with visualvm you can try the following:

使用以下选项启动Java进程:

Start your java process using the following options:

java -Dcom.sun.management.jmxremote.port=<port> \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.rmi.port=<port> \
-Djava.rmi.server.hostname=<boot2docker_ip> \
<Main>

您需要使用运行您的图像 - 公开< port> -p< port>:< port>

然后在 visualvm with < boot2docker_ip>:< port>

不应该太多不同于 boot2docker

这篇关于如何监控Docker中的java应用程序内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆