在学习DockerFile中看到[ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]中的-Djava.security.egd=file:/dev/./urandom就产生了疑问,日常启动springboot项目没有这个参数。然后对这个参数进行的搜索,还是有文章说明到了这个参数用于产生随机数,又不禁的疑问为什么要产生随机数。还是在stackoverflow.com的网站中看到了英文的解释。如下:
The purpose of that security property is to speed up tomcat startup. By default the library used to generate random number in JVM on Unix systems relies on /dev/random
. On docker containers there isn't enough entropy to support /dev/random
. See Not enough entropy to support /dev/random
in docker containers running in boot2docker. The random number generator is used for session ID generation. Changing it to /dev/urandom
will make the startup process faster.
明确的看到了随机数的产生用于session ID。好的继续疑问:
Not enough entropy to support /dev/random in docker containers running in boot2docker
在docker中没有足够的entropy(熵)支撑/dev/random。
继续:java dev urandom_JVM上的随机数与熵池策略(https://blog.csdn.net/weixin_34487462/article/details/115020324)看了这篇文章后心中的疑问疑窦已解大部分了