zl程序教程

您现在的位置是:首页 >  其他

当前栏目

记一次docker容器迁移后无法启动的解决

2023-04-18 16:55:26 时间

故障现象

昨天进行从阿里云服务器(CentOS 7.6)迁移docker容器到华为云服务器(Huawei Cloud EulerOS),迁移后容器无法启动,不停重启。

docker logs --tail=500  容器名称

#日志中翻查到报错

library initialization failed - unable to allocate file descriptor table - out of memoryAborted (core dumped)

解决方法

#修改docker 配置

sudo vim /etc/systemd/system/docker.service.d/override.conf

在配置中增加如下内容

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --default-ulimit nofile=65530:65530

然后检查启动配置是否正常

sudo systemctl edit docker

没有问题就重新加载配置并重启docker

sudo systemctl daemon-reload
sudo systemctl restart docker

原因分析

参照度娘帮我找到的文档,我查看了宿主Linux  和容器 的ulimit值都是65535。

参照解决异常:library initialization failed - unable to allocate file descriptor table - out of memoryAborted_weixin_316529的博客-CSDN博客

分析,当JDK8启动程序时会尝试为系统设置的"1073741816"个文件句柄分配内存,因为文件句柄数量十分巨大,就导致了即便分配10G运存还是Out Of Memory。旧版的Linux默认句柄数为1024,则不会出现该异常。

而我本次业务迁移了7个容器,无法启动的三个都是容器启动直接运行jar包的,也是JDK8。疑似问题的原因就是这个。

参考文档

Docker -库初始化失败-无法分配文件描述符表-内存不足 - 问答 - 腾讯云开发者社区-腾讯云

解决异常:library initialization failed - unable to allocate file descriptor table - out of memoryAborted_weixin_316529的博客-CSDN博客docker java library initialization failed - unable to allocate file descriptor table - out of memory_hkNaruto的博客-CSDN博客

[转]深入理解Docker ulimit(docker容器启动报错library initialization failed - unable to allocate file descriptor table - out of memory问题解决) - dirgo - 博客园