docker

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > 云和虚拟化 > docker > docker启动报错205/limit

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

作者:小白的程序员

Dcoker启动报错经常能看到 205/limit这个错误提示,这是告诉你linux操作系统的文件描述符设置的和Docker的不匹配,或者是设置的比较小了,本文介绍了docker启动报错205/limit的解决方案,需要的朋友可以参考下

背景

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

解决方案

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

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

# 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

[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的资料请关注脚本之家其它相关文章!

您可能感兴趣的文章:
阅读全文