docker start起不来怎么办(docker启动不起来)

admin3年前网络知识26

docker start起不来的解决办法:1、检查运行状态,然后通过“echo 3 > /proc/sys/vm/drop_caches”命令释放被占用的内存;2、通过“$netstat -nltp|grep ...”命令检查端口是否已经被占用,如果上线后发现占有,则改为可用端口再重启即可。

正文内容:

php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用

本教程操作环境:linux7.3系统、docker19.03版、Dell G3电脑。

docker start起不来怎么办?

Docker无法正常启动的原因及解决办法

概述

Docker启动异常表现

状态反复restaring,用命令查看

$docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES21c09be88c11 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 availableMem: 15G 14G 627M 195M 636M 726MSwap: 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.logJava 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.logJava 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=14032568964## 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 美国高防vps written. Default location: //core or core.1#

分析系统日志

查看系统日志,发现有大量由于内存溢出,进程被杀死的记录

$grep -i 'Out of Memory' /var/log/messagesApr 7 10:04:02 centos106 kernel: Out of memory: Kill process 1192 (java) score 54 or sacrifice childApr 7 10:08:00 centos106 kernel: Out of memory: Kill process 2301 (java) score 54 or sacrifice childApr 7 10:09:59 centos106 kernel: Out of memory: Kill process 28145 (java) score 52 or sacrifice childApr 7 10:20:40 centos106 kernel: Out of memory: Kill process 2976 (java) score 54 or sacrifice childApr 7 10:21:08 centos106 kernel: Out of memory: Kill process 3577 (java) score 47 or sacrifice childApr 7 10:21:08 centos106 kernel: Out of memory: Kill process 3631 (java) score 47 or sacrifice childApr 7 10:21:08 centos106 kernel: Out of memory: Kill process 3634 (java) score 47 or sacrifice childApr 7 10:21:08 centos106 kernel: Out of memory: Kill process 3640 (java) score 47 or sacrifice childApr 7 10:21:08 centos106 kernel: Out of memory: Kill process 3654 (java) score 47 or sacrifice childApr 7 10:27:27 centos106 kernel: Out of memory: Kill process 6998 (java) score 51 or sacrifice childApr 7 10:27:28 centos106 kernel: Out of memory: Kill process 7027 (java) score 52 or sacrifice childApr 7 10:28:10 centos106 kernel: Out of memory: Kill process 7571 (java) score 42 or sacrifice childApr 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 [规划的端口号](www.inhv.cn)》

本文从互联网转载,来源地址:www.inhv.cn/dockerjiaocheng/244978.html,原作者保留一切权利,若侵权或引用不当,请联系测速网(inhv.cn)删除。【测速网,优质云服务器提供商】

《docker start起不来怎么办(docker启动不起来)》来自互联网同行内容,若有侵权,请联系我们删除!

免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

怎么调节抖音弹幕透明度 抖音设置弹幕透明度方法

抖音怎么设置弹幕透明度,下面请看小编的详细介绍吧!首先进入到软件界面,点击【 弹幕 】进入进入到界面中点击【 弹 】进入最后进入到界面 设置透明度 即可以上就是抖音设置弹幕透明度的技巧,希望大家喜欢,...

爱教学app是什么?怎么样?靠谱吗?

爱教学app是一款专为教师提供教学辅导服务的客户端应用,爱教学软件方便老师对学生进行统一化管理,有效提升课堂教学质量,爱教学会自动收集整理学生互动数据。软件介绍爱教学,一款为老师提供教学服务的app,...

hp laserjet p1007打印机怎么连接电脑?打印机驱动下载安装的使用教程

hp laserjet p1007打印机怎么连接电脑?可以按照如下方式bai进行操作:1、打开du控制面板里面的“zhi设备和打印机”2、将打印机连接至主机,打开打印机电源,通...

抖音怎么拍3分钟视频

截止2020年7月24日,抖音只能录制60秒和15秒的视频,部分用户能拍一分钟的视频;所以不能用抖音拍摄3分钟的视频。 抖音(Tik Tok)是由今日头条推出的一款短视频分享APP,于2016年9月上...

抖音店铺保证金可以退吗

抖音保证金能退,申请退保证金即可。关店审核通过以后系统将提示店铺关闭后,商家可点击“申请退保证金”,如需要再次开启店铺,需在店铺关闭的6个月后操作。抖音短视频,是一款音乐创意短视频社交软件,由今日头条...

ipad 键盘分成两半了怎么恢复

当用户按住键盘左右两端,并且向外拉的时候,键盘就会自动拆分成两半,这是一个默认的功能。只需要两指按住左右键盘,向中间捏合就可以回到整个键盘的状态。iPad是由苹果公司于2010年开始发布的平板电脑系列...