当前位置: 代码网 > 服务器>服务器>云虚拟主机 > docker启动报错205/limit的解决方案

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

2024年07月02日 云虚拟主机 我要评论
背景dcoker启动报错经常能看到 205/limit这个错误提示,这是告诉你linux操作系统的文件描述符设置的和docker的不匹配,或者是设置的比较小了。解决方案linux中一切皆文件。例如一个

背景

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的资料请关注代码网其它相关文章!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com