今天我遇到了一个问题,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
我记得三天前我改变了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
我将 fd 增加到 100 万,撤消更改后,docker 成功启动
这里到底有什么问题?
答案1
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