• Home
  • Thread Dump and Heap Dump from a running container

Thread Dump and Heap Dump from a running container

15 May 2019 Bajrang Gupta Comments Off
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(Process id) appropriately.
     jstack PID > threadDump.tdump 
     
4. Then run the below command to get the Heapdump. 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 .