今天我遇到了 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
如果以下内容不存在,则创建此文件。重新加载
systemctl daemon-reload
docker 包设置的限制高于我们的新限制,因此进程无法启动。因此,如果上述选项对您不起作用,您可以在下面尝试。
sysctl -w fs.nr_open=1048576