站長資訊網
最全最豐富的資訊網站

docker start起不來怎么辦

docker start起不來的解決辦法:1、檢查運行狀態,然后通過“echo 3 > /proc/sys/vm/drop_caches”命令釋放被占用的內存;2、通過“$netstat -nltp|grep …”命令檢查端口是否已經被占用,如果上線后發現占有,則改為可用端口再重啟即可。

docker start起不來怎么辦

php入門到就業線上直播課:進入學習
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調試工具:點擊使用

本教程操作環境:linux7.3系統、docker19.03版、Dell G3電腦。

docker start起不來怎么辦?

Docker無法正常啟動的原因及解決辦法

概述

Docker啟動異常表現

狀態反復restaring,用命令查看

$docker ps -a CONTAINER ID    IMAGE  COMMAND       CREATED      STATUS       PORTS    NAMES 21c09be88c11     docker.xxxx.cn:5000/xxx-tes/xxx_tes:1.0.6   "/usr/local/tomcat..."   9 days ago          Restarting (1) Less than a second ago                      xxx10
登錄后復制

Docker日志有明顯問題:

$docker logs [容器名/容器ID] 比如: docker logs openresty
登錄后復制

Docker啟動異常的可能原因

內存不夠

Docker 啟動至少需要2G內存,首先執行free -mh命令查看剩余內存是否足夠

直接查看內存

$free -mh             total        used        free      shared  buff/cache   available Mem:         15G         14G          627M        195M        636M     726M Swap:         0B          0B          0B
登錄后復制

分析日志

有時候一瞬間內存過載溢出,導致部分進程被殺死,看起來內存也是夠用的,事實上docker還是會反復重啟,就需要通過docker日志和系統日志信的息來進一步分析:

分析docker日志

查看docker日志看到內存溢出的信息,要仔細翻閱才能找到信息,并不是在最下面

$docker logs [容器名/容器ID]|less  Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000769990000, 1449590784, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 1449590784 bytes for committing reserved memory. # An error report file with more information is saved as: # //hs_err_pid1.log Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000769990000, 1449590784, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 1449590784 bytes for committing reserved memory. # An error report file with more information is saved as: # /tmp/hs_err_pid1.log Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000769990000, 1449590784, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 1449590784 bytes for committing reserved memory. # Can not save log file, dump to screen.. # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 1449590784 bytes for committing reserved memory. # Possible reasons: #   The system is out of physical RAM or swap space #   In 32 bit mode, the process size limit was hit # Possible solutions: #   Reduce memory load on the system #   Increase physical memory or swap space #   Check if swap backing store is full #   Use 64 bit Java on a 64 bit OS #   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 (os_linux.cpp:2756), pid=1, tid=140325689620224 # # JRE version:  (7.0_79-b15) (build ) # Java VM: Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode linux-amd64 compressed oops) # Core dump written. Default location: //core or core.1 #
登錄后復制

分析系統日志

查看系統日志,發現有大量由于內存溢出,進程被殺死的記錄

$grep -i 'Out of Memory' /var/log/messages Apr  7 10:04:02 centos106 kernel: Out of memory: Kill process 1192 (java) score 54 or sacrifice child Apr  7 10:08:00 centos106 kernel: Out of memory: Kill process 2301 (java) score 54 or sacrifice child Apr  7 10:09:59 centos106 kernel: Out of memory: Kill process 28145 (java) score 52 or sacrifice child Apr  7 10:20:40 centos106 kernel: Out of memory: Kill process 2976 (java) score 54 or sacrifice child Apr  7 10:21:08 centos106 kernel: Out of memory: Kill process 3577 (java) score 47 or sacrifice child Apr  7 10:21:08 centos106 kernel: Out of memory: Kill process 3631 (java) score 47 or sacrifice child Apr  7 10:21:08 centos106 kernel: Out of memory: Kill process 3634 (java) score 47 or sacrifice child Apr  7 10:21:08 centos106 kernel: Out of memory: Kill process 3640 (java) score 47 or sacrifice child Apr  7 10:21:08 centos106 kernel: Out of memory: Kill process 3654 (java) score 47 or sacrifice child Apr  7 10:27:27 centos106 kernel: Out of memory: Kill process 6998 (java) score 51 or sacrifice child Apr  7 10:27:28 centos106 kernel: Out of memory: Kill process 7027 (java) score 52 or sacrifice child Apr  7 10:28:10 centos106 kernel: Out of memory: Kill process 7571 (java) score 42 or sacrifice child Apr  7 10:28:10 centos106 kernel: Out of memory: Kill process 7586 (java) score 42 or sacrifice child
登錄后復制

端口沖突

該docker監聽端口已經被其他進程占用,一般此種問題容易出現在新部署的服務,或在原有機器上部署新的后臺服務,所以在部署之前應該執行命令檢查端口是否已經被占用,如果上線后發現占有則應改為可用端口再重啟之。

檢查命令:    netstat -nltp|grep [規劃的端口號]
登錄后復制

解決方案

內存不夠的方案

進程在運行一段時間后占用大量內存,需要將其重啟。重啟命令可能有時并不起作用。主要檢查運行狀態,如果未成功停止,則重新重啟;

ELK日志收集程序或者其他java進程占用過高,用top和ps命令排查,謹慎確定進程的作用,在確保不影響業務的情況下,停止相關進程;

釋放被占用的內存(buff/cache)

 [root]# sync  #將內存數據寫入磁盤  [root]# echo 3 > /proc/sys/vm/drop_caches  #釋放被占用的內存
登錄后復制

有時候并不是buff/cache過高導致內存不夠用,確實是被很多必要的進程消耗掉了內存,那就需要從機器資源分配使用的層面去考慮和解決了。

端口沖突的對策

一般此種問題容易出現在新部署的服務,或在原有機器上部署新的后臺服務,所以在部署之前應該執行命令檢查端口是否已經被占用,如果上線后發現占有則應改為可用端口再重啟之。

檢查命令:    $netstat -nltp|grep [規劃的端口號]
登錄后復制

推薦學習:《docker視頻教程》

贊(0)
分享到: 更多 (0)
網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
人妻精品久久久久中文字幕 | 日韩字幕一中文在线综合| 亚洲国产精品网站在线播放 | 国语自产精品视频在线区| 3D动漫精品啪啪一区二区下载| 国产精品免费看久久久无码| 日韩久久无码免费毛片软件| 日韩免费视频网站| 国精无码欧精品亚洲一区| 99热在线精品免费播放6| 国产69精品久久久久久久| 日韩一级黄色录像| 精品亚洲一区二区三区在线播放| 无码人妻精品一区二区三| 99久久这里只精品国产免费| 亚洲国产日韩在线成人蜜芽| 久久精品视频91| 91亚洲国产成人久久精品网站| 91久久国产精品| 精品久久久久久无码中文字幕漫画| 日韩美女18网站久久精品| 国产乱码精品一区二区三区麻豆| 337P日本欧洲亚洲大胆精品| 国产乱人伦app精品久久| 99久久婷婷国产综合精品| 狠狠入ady亚洲精品| 国产精品午夜国产小视频| 99久久国产综合精品2020| 成人精品综合免费视频| 亚洲欧美日韩国产成人| 久久国产精品岛国搬运工| 久久综合久久精品| 国产精品亚洲自在线播放页码| 精品久久久久亚洲| 亚洲色精品88色婷婷七月丁香 | 久久久久久久91精品免费观看| 这里只有精品视频在线| 国产精品久久久久久久久| 精品国产香蕉伊思人在线又爽又黄 | 久久久久久噜噜精品免费直播| 亚洲精品国产手机|