docker啟動(dòng)報(bào)錯(cuò)205/limit的解決方案
背景
Dcoker啟動(dòng)報(bào)錯(cuò)經(jīng)常能看到 205/limit這個(gè)錯(cuò)誤提示,這是告訴你linux操作系統(tǒng)的文件描述符設(shè)置的和Docker的不匹配,或者是設(shè)置的比較小了。
解決方案
linux中一切皆文件。例如一個(gè)socket都會(huì)用一個(gè)文件描述符去表示,所以linux系統(tǒng)文件描述符的大小,對(duì)系統(tǒng)是至關(guān)重要的,例如高并發(fā)的時(shí)候,如果文件描述符太小,服務(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 # 這里按照實(shí)際情況填寫。 fs.nr_open = 6553600
修改文件使用執(zhí)行命令sysctl -p命令讓設(shè)置的內(nèi)容生效,并重啟docker systemctl restart docker
- 修改Docker的docker.service文件路徑
/usr/lib/systemd/system/docker.service文件中對(duì)文件描述符的配置,可以修改的比系統(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的啟動(dòng)配置文件, 文件路徑/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 正常啟動(dòng)。
以上就是docker啟動(dòng)報(bào)錯(cuò)205/limit的解決方案的詳細(xì)內(nèi)容,更多關(guān)于docker啟動(dòng)報(bào)錯(cuò)205/limit的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Linux環(huán)境下使用Docker搭建Jenkins容器的方法步驟
本文主要介紹了Linux環(huán)境下使用Docker搭建Jenkins容器的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06
Docker部署Java應(yīng)用程序的實(shí)現(xiàn)步驟
本文主要介紹了Docker部署Java應(yīng)用程序的實(shí)現(xiàn)步驟,通過(guò)將Java應(yīng)用程序打包成一個(gè)Docker鏡像,可以實(shí)現(xiàn)快速部署、資源隔離和靈活擴(kuò)展,感興趣的可以了解一下2024-03-03
docker部署高斯數(shù)據(jù)庫(kù)的詳細(xì)步驟
文章詳細(xì)介紹了如何在Docker中部署高斯數(shù)據(jù)庫(kù)(openGauss),包括安裝Docker、拉取鏡像、運(yùn)行容器、設(shè)置環(huán)境變量和掛載數(shù)據(jù)卷等步驟,還提供了連接和配置遠(yuǎn)程連接的指導(dǎo),感興趣的朋友一起看看吧2024-12-12
Docker基礎(chǔ) :網(wǎng)絡(luò)配置詳解
本篇文章將講述 Docker 的網(wǎng)絡(luò)功能,包括使用端口映射機(jī)制來(lái)將容器內(nèi)應(yīng)用服務(wù)提供給外部網(wǎng)絡(luò),以及通過(guò)容器互聯(lián)系統(tǒng)讓多個(gè)容器之間進(jìn)行快捷的網(wǎng)絡(luò)通信,有興趣的可以了解下。2017-02-02
Docker搭建Jenkins并自動(dòng)化打包部署項(xiàng)目的步驟
本文主要介紹了Docker搭建Jenkins并自動(dòng)化打包部署項(xiàng)目的步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03
Docker核心組件之聯(lián)合文件系統(tǒng)詳解
這篇文章主要為大家介紹了Docker核心組件之聯(lián)合文件系統(tǒng)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-04-04

