I want to profile a Java app inside a Docker container with JFR. How do I do so? The application I want to profile is not mine, so I can't alter the Dockerfile or any of the source code.
Docker run cmd:
docker run -itd --privileged --memory="_g" --cpuset-cpus x-y -p
p1:p1 -p p2:p2 -p p3:p3 -p p4:p4 -p p5:p5 --net=host -v
<hostDirectory>:<containerDirectory> --name=<containerName> <image>
Best Answer
If the Java app is running on a recent JDK, you may be able to attach to the process using jcmd and start a recording, i.e.