Is it possible to take a dump of a java process thread in a container from the host?

My java process is running inside the container. Of course, I see this process on the host machine and see its pid. If jdk is not installed in the cluster but on the host, I can run jstack from the host against the java process in the docker container using this pid. By the way, I tried and ran into the following error

Attaching to process ID 66367, please wait... Error attaching to process: Doesn't appear to be a HotSpot VM (could not find symbol "gHotSpotVMTypes" in remote process) sun.jvm.hotspot.debugger.DebuggerException: Doesn't appear to be a HotSpot VM (could not find symbol "gHotSpotVMTypes" in remote process) at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:411) at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305) at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140) at sun.jvm.hotspot.tools.Tool.start(Tool.java:185) at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118) at sun.jvm.hotspot.tools.JStack.main(JStack.java:92) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.tools.jstack.JStack.runJStackTool(JStack.java:140) at sun.tools.jstack.JStack.main(JStack.java:106) 
+7
java docker docker-container
source share
1 answer

The version of jstack used must come from the same version of the JVM in which your software runs.

Running jstack in the application container will work.

You can also run jstack in remote debugging after activating the remote debug server / jmx on your software.

Also, if there is no jstack in your container, you can run the container built with the same jvm, but send jstack in the same pid namespace of your jvm container by running:

docker run --pid=container:your_app your_jstack_images jstack $in_your_app_container_jvms_pid

0
source share

All Articles