How to set memory limit for Java 11 inside Docker? How to set memory limit for Java 11 inside Docker? docker docker

How to set memory limit for Java 11 inside Docker?


  1. As java 11 (10+) can automatically detect the container's memory you can set memory limit on your container and it should WAI:
docker run -m 512 .... 
  1. As for the choice of JDK, you can either use oracle JDK which is licensed or open source OpenJDK.

More details in this article: https://www.docker.com/blog/improved-docker-container-integration-with-java-10/


You can set the maximum heap size using the hotspot JVM -Xmx option (see java 11 options)

You may use AdoptOpenJDK for production as they are kept up tp date.