I have a java application running inside a docker container with OpenJDK11. I want to get GC data from this application using jstat tool (available inside a container). Any idea how can I achieve this from the host or another container running on the same host?
Thank you :)
The processes are visible on the host, so
jstat -gcstat <pid>works on the host if you know the pid as it is seen by the host.You can get the host-pid of a container-pid-1 via
docker inspect -f '{{.State.Pid}}' <container name>and then walk the process tree (e.g. via/procor some library encapsulating that logic) to find the java child process and then call jstat.Another option is to (partially) join the container's namespace via
nsenterordocker execand then just executejpsandjstatinside the container. But that can be a security concern if you don't trust the container.