Docker無法執行java虛擬機器報錯There is insufficient memory for the Java Runtime

轻寒發表於2024-08-21

映象匯入到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

相關文章