docker 报错 library initialization failed - unable to allocate file descriptor table - out of memory

这篇具有很好参考价值的文章主要介绍了docker 报错 library initialization failed - unable to allocate file descriptor table - out of memory。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

错误

docker容器,启动的时候 容器日志报: library initialization failed - unable to allocate file descriptor table - out of memory

原因

docker启动容器时,若未给容器配置ulimit,则从docker守护进程上设置的默认ulimits继承,这个值太大?会报这个错

官方文档:

dockerd | Docker Docs

ulimit nofile这个值太大报错的原因:

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

stackoverflow

解决方法

修改创建创建容器时的ulimit值,​​​​​​

这个是在启动容器的时候报错,而不是启动docker的时候,对整个系统影响最小的话,

优先修改的是docker创建容器时的ulimit值(法1),但这种每次都要加参数比较麻烦

所以推荐改docker守护进程的ulimit(法2),对整个系统影响最小的话,也不麻烦

还有就是修改系统内核的(法3),对整个系统影响较大不推荐

方法1

 docker run 或者docker-compose的时候加上ulimit配置。

docker run | Docker Docs

Services top-level elements | Docker Docs

方法2(推荐)

修改docker创建容器的默认ulimit配置。

步骤如下:

查看docker的systemd配置位置

systemctl status docker

library initialization failed - unable to allocate file descriptor table - o,docker,容器,运维

编辑docker.service

在ExecStart命令后加上创建容器的默认ulimit配置,如下,设置容器启动时的ulimit为65535:65535:

 --default-ulimit nofile=65535:65535

配置好的样子

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --default-ulimit nofile=65535:65535

重启docker 

systemctl daemon-reload
systemctl restart docker

方法3

 修改系统内核的ulimits
  • 使用 ulimit 命令:
ulimit -n <new limit>
  • 修改 /etc/security/limits.conf 文件:

在 /etc/security/limits.conf 文件中添加或修改以下行:

* soft nofile <new limit>
* hard nofile <new limit>
  • 使用 sysctl 命令:
sysctl -w fs.file-max=<new limit>

更多细节

docker守护进程的ulimits由哪来

linux系统服务limitnofile,systemd中设置LimitNOFILE=infinity最终却得到65536-CSDN博客

docker守护进程的ulimits由systemd控制,一般再docker systemd的配置里写。(systemctl版本小于234的时候不生效,查看systemctl版本:systemctl --version)

docker 启动报错 library initialization failed - unable to allocate file descriptor table - out of memory-CSDN博客systemd的ulimits由系统内核控制?可以更改

library initialization failed - unable to allocate file descriptor table - o,docker,容器,运维

2024年3月29日,docker版本20.10.17,系统版本麒麟v10,经过实际测试,启动容器的时候不设置ulimit,不会继承守护进程的ulimit,在systemd中配置的对容器无用。只有法2可行。

查看docker守护进程的ulimits

cat /proc/`pidof dockerd`/limits |grep files

查看容器的ulimits

docker inspect -f '{{.State.Pid}}' 容器id
# 输出pid
cat /proc/pid/limits |grep files

通过其他前辈的博客总结而来,侵删

https://www.jianshu.com/p/30618c96b343

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

java - Error upon jar execution - unable to allocate file descriptor table - Stack Overflow文章来源地址https://www.toymoban.com/news/detail-861627.html

到了这里,关于docker 报错 library initialization failed - unable to allocate file descriptor table - out of memory的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Failed to initialize NVML: Driver/library version mismatch (解决)

    运行 nvidia-smi 报错: 只需一步:下载一个安装包,运行一个命令来重新安装 cuda driver 和 cuda toolkit (在一个包里)。 到这里:https://developer.nvidia.com/cuda-toolkit-archive 选择要下载的安装包。 点击要下载的版本后,下载对应的安装包,这个安装包包括 Driver(驱动) Cuda toolkit (工具

    2024年02月16日
    浏览(28)
  • Docker 报错:OCI runtime exec failed: exec failed: unable to start container process: exec: “xxx“: exec

    前言 最近在学狂神 Docker 网络时遇到的问题,查看容器内部网络地址报错信息如上。 报错原因: 我们下载的Tomcat镜像是精简版的,运行并进入 tomcat01 容器后发现没有ip addr 和 ping 命令。 解决方式: 安装 iproute2:apt install -y iproute2 安装 ping:apt-get install -y iputils-ping 解决过程

    2024年02月02日
    浏览(24)
  • 使用Docker 报错OCI runtime exec failed: exec failed: unable to start container process: exec: “xxx“: exe

    前些天在使用 Docker 运行一个容器时,遇到了一个报错:OCI runtime exec failed: exec failed: unable to start container process: exec: “xxx“: exec。 这个错误让我有些烦躁,因为我刚刚将容器创建好,准备执行相关命令时,却发现容器无法正常启动。在经过一番排查和尝试后,我终于找到了解

    2024年02月15日
    浏览(17)
  • pyrender库报错解决方法:‘Unable to load OpenGL library’

    在 pip install pyrender 成功安装后,调用 pyrender 库时报错: OSError: (‘GL: cannot open shared object file: No such file or directory’, ‘GL’, None) ImportError: (‘Unable to load OpenGL library’, ‘GL: cannot open shared object file: No such file or directory’, ‘GL’, None) 报错截图: 这种问题一般会出现在本机/d

    2024年01月21日
    浏览(37)
  • win10 hadoop报错 unable to load native-hadoop library

    win10 安装hadoop执行hdfs -namenode format 和运行hadoop的start-all报错 unable to load native-hadoop library 验证: hadoop checknative -a 这个命令返回都是false是错的 返回下图是正确的 winutils: true D:softhadoop-3.0.0binwinutils.exe Native library checking: hadoop:  true D:softhadoop-3.0.0binhadoop.dll zlib:    false

    2024年02月15日
    浏览(20)
  • linux开启防火墙后,Docker容器启动报错:ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule 解决办法

    目录 1、错误场景和现象 2、原因分析 3、解决办法 linux开启或重启防火墙后,创建docker自定义网络时 报错: [root@VM-16-5-centos home]# docker network create --driver bridge --subnet 192.168.0.0/16 --gateway 192.168.0.1 frayernet Error response from daemon: Failed to Setup IP tables: Unable to enable SKIP DNAT rule:  (ipta

    2024年02月12日
    浏览(19)
  • 学习狂神docker报错解决:exec failed: unable to start container process: exec: “ip“: executable file not found

    问题:最近学习狂神的docker,34节,网络详解。下载tomcat镜像并启动成功。如图  在使用命令:   docker exec -it tomcat01 ip addr 查看容器ip地址时报错:OCI runtime exec failed: exec failed: unable to start container process: exec: \\\"ip\\\": executable file not found in $PATH: unknown  解决方案:安装工具 iproute

    2024年02月12日
    浏览(20)
  • Docker中Failed to initialize NVML: Unknown Error

    参考资料 Docker 中无法使用 GPU 时该怎么办(无法初始化 NVML:未知错误) 按照下面这篇文章当中引用的文章来(附录1) SOLVED Docker with GPU: “Failed to initialize NVML: Unknown Error” 解决方案需要的条件: 需要在服务器上docker的admin list之中. 不需要服务器整体的admin权限. 我在创建d

    2024年02月06日
    浏览(24)
  • windows运行elasticsearch报错Native memory allocation (mmap) failed to map 4294967296 bytes for G1

    今天下载了一个elasticsearch8.4.3 windows版本的es,配置好相应的配置后,启动bat文件,输出一行信息后,窗口就闪退了。于是通过cmd窗口运行,发现了报错信息如下 解决办法如下,修改config目录下的jvm.options文件,    32行和33行是配置java内存的,这里注释掉,就是默认是没有配置

    2024年02月16日
    浏览(16)
  • vscode报错“Unable to start debugging”“GDB Failed with message:”

    1、正常打开文件夹,新建一个cpp;  2、配置编译器,ctrl shift p,C/C++,edit configration ui 3、运行,启动调试,弹出任务,默认选择第一个, 直接报错“Unable to start debugging”“GDB Failed with message:”  此时,有怀疑路径中文的,怀疑项目,千奇百怪,本质原因是第3步选择,编译

    2024年02月16日
    浏览(19)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包