What does this option do in docker file?
ENTRYPOINT java -XX:+UseContainerSupport $JAVA_OPTIONS -jar /myapp.jar
Will the docker container start without this parameter? I checked one article which says
enable memory support
but it is still not clear to me.
Starting from Java 10, this parameter (which is enabled by default) is used to make the JVM take the container memory limits into account when allocating the heap size, not the host machine configuration.
This option was backpacked to Java 8: https://www.oracle.com/technetwork/java/javase/8u191-relnotes-5032181.html
Examples:
If you run:
The result is going to be (on my machine Ubuntu with 8gb)
I set a memory limit for the container but it ignored and used the host config (it uses by default total memory/4)
Now if I run the version that has the new feature (link above) you can see that the container memory limite was taken into account:
Result (total memory / 4):
At the time I'm writing the LATEST version of the openjdk:8 image is the 222 so you can use this version, that has the feature backpacked.
For more information:
Explains this flag use in Java 10: https://medium.com/adorsys/jvm-memory-settings-in-a-container-environment-64b0840e1d9e
Using this flag with Java 8: https://blog.softwaremill.com/docker-support-in-new-java-8-finally-fd595df0ca54
Yes. The container will start without
-XX:+UseContainerSupport
.-XX:+UseContainerSupport
is used to allocate a larger fraction of memory.To prevent the JVM adjusting the maximum heap size when running in a container, set
-XX:-UseContainerSupport
.In addition to that, https://www.eclipse.org/openj9/docs/xxusecontainersupport/ might be helpful.