翼度科技»论坛 云主机 服务器技术 查看内容

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

3

主题

3

帖子

9

积分

新手上路

Rank: 1

积分
9
背景

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

解决方案

linux中一切皆文件。例如一个socket都会用一个文件描述符去表示,所以linux系统文件描述符的大小,对系统是至关重要的,例如高并发的时候,如果文件描述符太小,服务器的并发是上不去的。
要解决
  1. 205/limit
复制代码
可以使用两种方式。

  • 修改系统文件描述符
    1. vim /etc/sysctl.conf
    复制代码

  1. # sysctl settings are defined through files in
  2. # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
  3. #
  4. # Vendors settings live in /usr/lib/sysctl.d/. # To override a whole file, create a new file with the same in
  5. # /etc/sysctl.d/ and put new settings there. To override
  6. # only specific settings, add a file with a lexically later
  7. # name in /etc/sysctl.d/ and put new settings there. # # For more information, see sysctl.conf(5) and sysctl.d(5).
  8. fs.file-max =6553600 # 这里按照实际情况填写。
  9. fs.nr_open = 6553600
复制代码
修改文件使用执行命令
  1. sysctl -p
复制代码
命令让设置的内容生效,并重启docker
  1. systemctl restart docker
复制代码

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

  8. [Service]
  9. Type=notify
  10. # the default is not to use systemd for cgroups because the delegate issues still
  11. # exists and systemd currently does not support the cgroup feature set required
  12. # for containers run by docker
  13. 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
  14. ExecReload=/bin/kill -s HUP $MAINPID
  15. TimeoutSec=0
  16. RestartSec=2
  17. Restart=always

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

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

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

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

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

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

  38. [Install]
  39. WantedBy=multi-user.target
复制代码
修改完Docker后,可能还需要修改containerd的启动配置文件, 文件路径
  1. /usr/lib/systemd/system/containerd.service
复制代码
  1. [Unit]
  2. Description=containerd container runtime
  3. Documentation=https://containerd.io
  4. After=network.target

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

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

来源:https://www.jb51.net/server/3234652d8.htm
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

举报 回复 使用道具