I'm deploying a Java Spring-Boot application as a Docker container to servers having 16 GB of memory.
The Docker server version is 19.03.12 on a Ubuntu 18.04.4 LTS. My Docker image has openjdk-11 as the Java runtime installed. The entrypoint is defined as:
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
I start the container without any restrictions to CPU and memory, but the application dies always with an OutOfMemoryError when the Heap space reaches 8 GB. There are running some other containers, but the system has still around 3-4 GB of free memory.
Why is the JVM inside the container somehow limited to use 8 GB of memory, although is 'sees' the entire 16 GB? What do I have to do that the JVM is allowed to consume as much memory the system provides?