Home > Java > javaTutorial > Get thread dump of Java container running on JRE Docker image

Get thread dump of Java container running on JRE Docker image

Patricia Arquette
Release: 2024-11-03 22:24:31
Original
587 people have browsed it

Given an webapp running with a JRE-based docker image in Kubernetes cluster, example: tomcat:9.0-jre11-temurin, then getting the thread dump is not easy as the JRE-based docker image does not include the tools like jstack, jmap...

We can use jattach tools to get our task done. TLDR; jattach is a compact tool written in C by Andrei Pangin.

First we need to download the tool to container:

Open the shell in the container:

kubectl -n default exec -it your-tomcat-pod -c your-tomcat-container -- bash
Copy after login

Download the jattach to the working dir

cd /working-dir

curl -L -O https://github.com/apangin/jattach/releases/download/v2.2/jattach 

chmod +x jattach
Copy after login

From your terminal create thread dump and store in the output file

kubectl -n default exec your-tomcat-pod \
  -c your-tomcat-container  -- \
  /working-dir/jattach 1 threaddump > thread-dump.txt
Copy after login

Then you can use jstack.review tool to analyze the thread dump.

Get thread dump of Java container running on JRE Docker image

The above is the detailed content of Get thread dump of Java container running on JRE Docker image. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template