Docker无法运行java虚拟机报错There is insufficient memory for the Java Runtime
镜像导入到docker后无法启动容器的问题,但是上传到别的服务器上面又可以正常启动容器,报错信息如下:
# There is insufficient memory for the Java Runtime Environment to continue. # Cannot create GC thread. Out of system resources. # Can not save log file, dump to screen.. # # There is insufficient memory for the Java Runtime Environment to continue. # Cannot create GC thread. Out of system resources. # 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= # This output file may be truncated or incomplete. # # Out of Memory Error (gcTaskThread.cpp:48), pid=1, tid=0x00007efe049adb40 # # JRE version: (8.0_412-b08) (build ) # Java VM: OpenJDK 64-Bit Server VM (25.412-b08 mixed mode linux-amd64 compressed oops) # Core dump written. Default location: /chint-py-upms/core or core.1
看上去是说服务器资源不足,内存不够,但是执行free -h查看了一下内存并没有不足,经过资料排查最终确定是docker内核版本过低导致的,升级docker版本即可解决。
升级之后docker version查看版本:
可能出现问题:
docker 升级后或者重装后,因为版本问题启动容器提示:Error response from daemon: Unknown runtime specified docker-runc。
解决方法:
更改/var/lib/docker/containers目录中的文件参数,把docker-runc替换为runc。
命令:
grep -rl 'docker-runc' /var/lib/docker/containers/ | xargs sed -i 's/docker-runc/runc/g'
注:grep -rl:递归搜索目录和子目录,只列出含有匹配的文本行的文件名,而不显示具体的匹配内容
重新启动docker即可解决
systemctl restart docker