刄省惪椅序静帆 发表于 2024-7-6 08:41:39

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文件中对文件描述符的配置,可以修改的比系统配置的最大文件描述符小一些

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


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


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

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


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


WantedBy=multi-user.target修改文件后先执行 systemctl daemon-reload 然后执行 systemctl restart docker docker 正常启动。
以上就是docker启动报错205/limit的解决方案的详细内容,更多关于docker启动报错205/limit的资料请关注脚本之家其它相关文章!

来源:https://www.jb51.net/server/3234652d8.htm
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: docker启动报错205/limit的解决方案