I need to run JCMD on prod to monitor my application, but unfortunately I can't have a proper JDK in place so I need to run it with a JRE. I can add some dependencies, but not the whole jdk.
I'm using openJDK 8.
Does anyone know how to do it?
There was one question already posted here (How to run jcmd without the JDK?), but the answer works for windows servers, not for linux OS in a docker container.
In my personal experience
jcmd
from newer version of Java works with the older versions. You can exploit the multi-stage build feature and havejlink
elegantly package for you the (strictly) necessary files, please refer to thisDockerfile
:In case you prefer, I give you "an" answer for Java 8, using adoptopenjdk and multistage build
in this case
jcmd
gets installed along the jre installation, in the same bin folder as java.I tested both of them in both docker-desktop 20.10.7 and Mirantis (Docker Enterprise) 3.3.11.