Introduction
Sometimes we need to debug our docker applications with the use of Thread/Heap dump, below is a simple and quick way to do it from docker container
Environment
- Vagrant: (Ubuntu 18.04)
- Example of docker container: java-example
Thread dump
Following steps will allow take thread dumps from a docker container, and then copy saved file into to host
- Run example application:
root@vagrant:/home/vagrant# docker run -d bitnami/java-example:0.0.1
- Run the below command and go into the container.
root@vagrant:/home/vagrant# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bf342a25fc61 bitnami/java-example:0.0.1 "java -jar jenkins.w…" 2 seconds ago Up 1 second 8080/tcp competent_dubinsky
root@vagrant:/home/vagrant# docker exec -it bf342a25fc61 bash
- Find PID of java process (First column is user that run the process, second column PID)
root@bf342a25fc61:/app# ps -fea|grep -i java
root 1 0 2 19:02 ? 00:00:06 java -jar…