Skip to content

Instantly share code, notes, and snippets.

@snallami
Created October 12, 2016 01:13
Show Gist options
  • Save snallami/99bca3766420fd5a155dff89952e2495 to your computer and use it in GitHub Desktop.
Save snallami/99bca3766420fd5a155dff89952e2495 to your computer and use it in GitHub Desktop.
Docker thread dump
https://dkbalachandar.wordpress.com/2016/07/05/thread-dump-from-a-docker-container/
Thread & Heap dumps From a Docker container
Follow the below steps to take the thread and Heap dumps from a docker container
1. Run the below command to bash into the container. Please change the CONTAINER_NAME appropriately
docker exec -it CONTAINER_NAME bash
2. Then type jps to find the all the Java application details and extract the PID for your application
jps
3. Then run the below command to get the thread dump. Please change the PID appropriately
jstack PID > threadDump.tdump
4. Then run the below command to get the Heap dump. Please change the PID appropriately
jmap -dump:live,format=b,file=heapDump.hprof PID
5. Then exit from the docker container and download the threadDump.tdump and heapDump.hprof from the docker container by running the below command. Please change the CONTAINER_NAME appropriately
sudo docker cp CONTAINER_NAME:threadDump.tdump .
sudo docker cp CONTAINER_NAME:heapDump.hprof .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment