背景
容器内运行的是Java程序,基础镜像从ubuntu18.04升级到ubuntu22.04,在公司环境部署可以正常启动,但是部署到业主环境,无法正常启动。通过docker logs 查看,报错信息如下:
There is insufficient memory for the Java Runtime Environment to continue.
Cannot create GC thread. Out of system resources.
The error accompanies the following information:
Possible reasons: The system is out of physical RAM or swap space The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap.
Possible solutions:
Reduce memory load on the system
Increase physical memory or swap space
Check if swap backing store is full
Decrease Java heap size (-Xmx/-Xms)
Decrease number of Java threads
Decrease Java thread stack sizes (-Xss)
Set larger code cache with -XX:ReservedCodeCacheSize=
解决方案:
通过比较两边的宿主机环境,发现docker的版本存在差异。公司环境的版本为:20.10.12 ,而业主环境的docker版本为:20.10.0.
再进一步通过搜索,确定为docker老版本对ubuntu22.04的兼容性问题, stackoverflow上已经有人提出相似问题。docker - Container Fails to Start: Insufficient memory for the Java Runtime Environment to continue - Stack Overflow
因此,果断升级业主的docker版本,即解决了问题。