I am running a simple spring-boot application inside a docker container. At startup whether started with java -jar MY_JAR.jar
or mvn spring-boot:run
For those who might come here later. I think easiest solution is to modify Dockerfile and have entry point as follows:
ENTRYPOINT ["java", **"-Djava.security.egd=file:/dev/./urandom"**,"-jar","app.jar"]
Had experience with apps hanging anywhere between 30 seconds and 15 minutes (or maybe more, but got killed).
From the other post that shares details:
Without this, Java uses /dev/random
to seed its SecureRandom
class, which can cause Java code to block unexpectedly.
Alternatively, in the $JAVA_HOME/jre/lib/security/java.security
configuration file, add the line
securerandom.source=file:/dev/./urandom
Footnote: In the above examples, you need the crazy-looking filename, e.g., the extra /./
, to trick Java into accepting your filename. If you just use /dev/urandom, Java decides you didn't really mean it and replaces what you wrote with /dev/random. Craziness!