docker啟動報錯205/limit的解決方案
背景
Dcoker啟動報錯經(jīng)常能看到 205/limit
這個錯誤提示,這是告訴你linux操作系統(tǒng)的文件描述符設(shè)置的和Docker的不匹配,或者是設(shè)置的比較小了。
解決方案
linux中一切皆文件。例如一個socket都會用一個文件描述符去表示,所以linux系統(tǒng)文件描述符的大小,對系統(tǒng)是至關(guān)重要的,例如高并發(fā)的時候,如果文件描述符太小,服務(wù)器的并發(fā)是上不去的。
要解決 205/limit
可以使用兩種方式。
- 修改系統(tǒng)文件描述符
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
修改文件使用執(zhí)行命令sysctl -p
命令讓設(shè)置的內(nèi)容生效,并重啟docker systemctl restart docker
- 修改Docker的docker.service文件路徑
/usr/lib/systemd/system/docker.service
文件中對文件描述符的配置,可以修改的比系統(tǒng)配置的最大文件描述符小一些
[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
修改文件后先執(zhí)行 systemctl daemon-reload
然后執(zhí)行 systemctl restart docker
docker 正常啟動。
以上就是docker啟動報錯205/limit的解決方案的詳細內(nèi)容,更多關(guān)于docker啟動報錯205/limit的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
docker image tag為什么出現(xiàn)none的原因及解決
當(dāng)我們使用docker加載新的鏡像時,有時候會發(fā)現(xiàn)Repository和Tag名稱都為none的情況,這通常是由于沒有指定正確的標(biāo)簽名稱或者倉庫名稱所導(dǎo)致的,本文主要介紹了docker image tag為什么出現(xiàn)none的原因及解決,感興趣的可以了解一下2023-10-10使用 docker部署tomcat并接入skywalking的使用
這里主要介紹了使用 docker 部署 tomact 并接入 skywalking 的使用,因為在網(wǎng)上并沒有查到太多相關(guān)的信息,所以這里記錄下來,需要對有需求的小伙伴提供一些幫助2021-04-04docker使用Dockerfile構(gòu)建鏡像的方法
這篇文章主要介紹了docker使用Dockerfile構(gòu)建鏡像的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12