docker启动报错205/limit的解决方案

 更新时间:2024年06月28日 14:51:01   作者:小白的程序员  
Dcoker启动报错经常能看到 205/limit这个错误提示,这是告诉你linux操作系统的文件描述符设置的和Docker的不匹配,或者是设置的比较小了,本文介绍了docker启动报错205/limit的解决方案,需要的朋友可以参考下

背景

Dcoker启动报错经常能看到 205/limit这个错误提示,这是告诉你linux操作系统的文件描述符设置的和Docker的不匹配,或者是设置的比较小了。

解决方案

linux中一切皆文件。例如一个socket都会用一个文件描述符去表示,所以linux系统文件描述符的大小,对系统是至关重要的,例如高并发的时候,如果文件描述符太小,服务器的并发是上不去的。

要解决 205/limit 可以使用两种方式。

  • 修改系统文件描述符 vim /etc/sysctl.conf
# sysctl settings are defined through files in 
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/. 
# 
# Vendors settings live in /usr/lib/sysctl.d/. # To override a whole file, create a new file with the same in 
# /etc/sysctl.d/ and put new settings there. To override 
# only specific settings, add a file with a lexically later 
# name in /etc/sysctl.d/ and put new settings there. # # For more information, see sysctl.conf(5) and sysctl.d(5). 
fs.file-max =6553600 # 这里按照实际情况填写。
fs.nr_open = 6553600

修改文件使用执行命令sysctl -p命令让设置的内容生效,并重启docker systemctl restart docker

  • 修改Docker的docker.service文件路径/usr/lib/systemd/system/docker.service文件中对文件描述符的配置,可以修改的比系统配置的最大文件描述符小一些
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --exec-opt=native.cgroupdriver=cgroupfs --log-level=warn --log-opt max-size=50M --storage-driver=overlay2 -H fd:// --containerd=/run/containerd/containerd.sock -H unix:///var/run/docker.sock -H tcp://0.0.0.0:900 --data-root=/data1/docker_customized
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=6553500     # 修改这里
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

修改完Docker后,可能还需要修改containerd的启动配置文件, 文件路径/usr/lib/systemd/system/containerd.service

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
KillMode=process
Delegate=yes
LimitNOFILE=6553500   # 修改这里
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity

[Install]
WantedBy=multi-user.target

修改文件后先执行 systemctl daemon-reload 然后执行 systemctl restart docker docker 正常启动。

以上就是docker启动报错205/limit的解决方案的详细内容,更多关于docker启动报错205/limit的资料请关注脚本之家其它相关文章!

相关文章

  • docker修改默认存储位置图文教程

    docker修改默认存储位置图文教程

    最近在学习docker的路上,今天遇到了个问题,在网上查找了一下资料,顺便留个笔记,下面这篇文章主要给大家介绍了关于docker修改默认存储位置的相关资料,需要的朋友可以参考下
    2022-09-09
  • Linux环境下使用Docker搭建Jenkins容器的方法步骤

    Linux环境下使用Docker搭建Jenkins容器的方法步骤

    本文主要介绍了Linux环境下使用Docker搭建Jenkins容器的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2022-06-06
  • Docker 的健康检测机制

    Docker 的健康检测机制

    这篇文章主要介绍了Docker 的健康检测机制。即检验进程是否存活,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-12-12
  • Docker部署Java应用程序的实现步骤

    Docker部署Java应用程序的实现步骤

    本文主要介绍了Docker部署Java应用程序的实现步骤,通过将Java应用程序打包成一个Docker镜像,可以实现快速部署、资源隔离和灵活扩展,感兴趣的可以了解一下
    2024-03-03
  • docker部署高斯数据库的详细步骤

    docker部署高斯数据库的详细步骤

    文章详细介绍了如何在Docker中部署高斯数据库(openGauss),包括安装Docker、拉取镜像、运行容器、设置环境变量和挂载数据卷等步骤,还提供了连接和配置远程连接的指导,感兴趣的朋友一起看看吧
    2024-12-12
  • Docker基础 :网络配置详解

    Docker基础 :网络配置详解

    本篇文章将讲述 Docker 的网络功能,包括使用端口映射机制来将容器内应用服务提供给外部网络,以及通过容器互联系统让多个容器之间进行快捷的网络通信,有兴趣的可以了解下。
    2017-02-02
  • Docker搭建Jenkins并自动化打包部署项目的步骤

    Docker搭建Jenkins并自动化打包部署项目的步骤

    本文主要介绍了Docker搭建Jenkins并自动化打包部署项目的步骤,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-03-03
  • Docker核心组件之联合文件系统详解

    Docker核心组件之联合文件系统详解

    这篇文章主要为大家介绍了Docker核心组件之联合文件系统详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-04-04
  • Docker镜像存储overlayfs的使用

    Docker镜像存储overlayfs的使用

    这篇文章主要介绍了Docker镜像存储overlayfs的使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-02-02
  • docker 查看jvm内存占用方式

    docker 查看jvm内存占用方式

    这篇文章主要介绍了docker 查看jvm内存占用方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2021-03-03

最新评论