Remix.run Logo
▲ gavinray a day ago

On that note, here's my favorite little-known tip for running Docker/Container JVM apps:

The Redhat image distros, like UBI and the JDK ones, have a really handy bash script, "run-java.sh". It's a wrapper script for best-practice and intelligent JVM runtime args inside of container envs:

  /opt/jboss/container/java/run/run-java.sh
It started life as fabric8's run-java-sh, and it's what the Dockerfile.jvm generated by Quarkus apps uses as its entrypoint.

The script handles, among other things:

- Heap sized as a percentage of the container's memory limit via -XX:MaxRAMPercentage (default 80%, compared with JVM's default of 25%). Tunalbe with JAVA_MAX_MEM_RATIO env.

- -XX:+ExitOnOutOfMemoryError, so an OOM kills the container and your orchestrator restarts it

- Defaults for GC and metaspace

- JAVA_DEBUG=true / JAVA_DEBUG_PORT=*:5005 turns on JDWP without you having to edit the Dockerfile

- http_proxy/https_proxy/no_proxy env vars get translated into -Dhttp.proxyHost etc

▲brunoborges 19 hours ago | parent [-]

Yeap! JVM launchers are extremely helpful. At Microsoft, I helped design `jaz` (https://aka.ms/jaz) for this purpose!