Linux

Docker 無法啟動

  • January 28, 2020

今天我遇到了 docker 的問題,它停止了,我無法啟動它

systemctl status docker

● docker.service - Docker Application Container Engine
  Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since Tue 2020-01-28 09:59:03 +0330; 1min 51s ago
    Docs: https://docs.docker.com
 Process: 2327 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=205/LIMITS)
Main PID: 2327 (code=exited, status=205/LIMITS)

Jan 28 09:59:03 example.com systemd[1]: Starting Docker Application Container Engine...
Jan 28 09:59:03 example.com systemd[1]: docker.service: main process exited, code=exited, status=205/LIMITS
Jan 28 09:59:03 example.com systemd[1]: Stopped Docker Application Container Engine.
Jan 28 09:59:03 example.com systemd[1]: Unit docker.service entered failed state.
Jan 28 09:59:03 example.com systemd[1]: docker.service failed.

我看到了status=205/LIMITS我記得 3 天前我更改了ulimit配置

# /etc/security/limits.d/custom.conf

root soft nofile 1000000
root hard nofile 1000000
* soft nofile 1000000
* hard nofile 1000000
# /etc/sysctl.conf

fs.file-max = 1000000
fs.nr_open = 1000000

在撤消更改docker成功啟動後,我將fd增加到100萬

這裡到底有什麼問題?

status=205/LIMITS表示這些限制命中之一LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=, LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=, LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=, LimitRTTIME=

我不確定您的作業系統版本,但舉一個 Ubuntu 16 的範例,/etc/systemd/system/docker.service.d/customexec.conf如果以下內容不存在,則創建此文件。

[Service]
LimitNOFILE=1000000

重新載入systemctl daemon-reload

docker 包設置的限制高於我們的新限制,因此程序無法啟動。因此,如果上述選項對您不起作用,您可以在下面嘗試。

sysctl -w fs.nr_open=1048576

引用自:https://serverfault.com/questions/1000684