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 .
    

Advertisements

One thought on “Thread & Heap dumps From a Docker container

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s