Spring-boot application won't boot at startup inside docker

后端 未结 2 1826
一生所求
一生所求 2020-12-23 12:17

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

2条回答
  •  醉梦人生
    2020-12-23 13:19

    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!

提交回复
热议问题