- Replace the
myapp.jar
in the Dockerfile with your jar file andEXPOSE 8080
with your port. - Define a default maxmimum memory usage, by setting
MAXRAMIFNOLIMIT
to another value (size in MiB). It will be used, when you run the docker container without memory limits, or when its memory limits are larger than this value. - You can pass Spring Profiles, e.g. to activate a profile in your application.yml, by writing them to the
springprofiles
environment variable, when you start the container. - Replace
Europe/Berlin
with your timezone, or remove the line to get UTC time.
When running Java in a Docker container, you have to care about memory limits.
By default OpenJDK tries to read the maximum memory of the computer, to calculate its maximum heap space.
When running in a container, a java application reads the memory size of the host computer.
Thats why you have to define the maximum heap size manually, especially when you run you container with memory limits.
Read this article for further information.
The correct memory limits inside a container can be found in /sys/fs/cgroup/memory/memory.limit_in_bytes
This is already integrated in the Dockerfile above.
To prevent delays caused by the random number generator, use /dev/./urandom
instead of /dev/random
See also Avoiding JVM Delays Caused by Random Number Generation.
This is already integrated in the Dockerfile above.
The RAM problem seems to be fixed at least in Java 8u191 and Java 10.
See https://bugs.openjdk.java.net/browse/JDK-8146115#jbs-backportsPanel
I tested it a few days ago with the openjdk:8u212-jre-slim-stretch image.