在安装docker时出现了非常怪异的问题,安装步骤均按照官网文档一步一步安装,没想到在安装过程中报错,信息如下:
Setting up docker-ce (17.12.1~ce-0~ubuntu) ...
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2018-03-19 13:52:20 CST; 11ms ago
Docs: https://docs.docker.com
Process: 5988 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=205/LIMITS)
Main PID: 5988 (code=exited, status=205/LIMITS)
Mar 19 13:52:20 swdmes-dev systemd[1]: Failed to start Docker Application Container Engine.
Mar 19 13:52:20 swdmes-dev systemd[1]: docker.service: Unit entered failed state.
Mar 19 13:52:20 swdmes-dev systemd[1]: docker.service: Failed with result 'exit-code'.
dpkg: error processing package docker-ce (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Errors were encountered while processing:
docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
查看docker状态
$ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Mon 2018-03-19 13:52:21 CST; 4min 32s ago
Docs: https://docs.docker.com
Process: 6001 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=205/LIMITS)
Main PID: 6001 (code=exited, status=205/LIMITS)
Mar 19 13:52:21 swdmes-dev systemd[1]: Failed to start Docker Application Container Engine.
Mar 19 13:52:21 swdmes-dev systemd[1]: docker.service: Unit entered failed state.
Mar 19 13:52:21 swdmes-dev systemd[1]: docker.service: Failed with result 'exit-code'.
Mar 19 13:52:21 swdmes-dev systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Mar 19 13:52:21 swdmes-dev systemd[1]: Stopped Docker Application Container Engine.
Mar 19 13:52:21 swdmes-dev systemd[1]: docker.service: Start request repeated too quickly.
Mar 19 13:52:21 swdmes-dev systemd[1]: Failed to start Docker Application Container Engine.
查看系统日志
$ sudo journalctl -xe
systemd[6764]: docker.service: Failed at step LIMITS spawning /usr/bin/dockerd: Operation not permitted
解决方案
修改系统的打开最大文件数:参考博客
具体原因我们根据错误提示status=205/LIMITS是不是有什么限制问题,之前也遇到过类似的错误提示,也是在启动容器时报的错,当时所用的容器为systemd-nspawn容器,
一开始排查思路异味权限错误导致,后来经过多方排查,发现是文件的最大打开文件数导致。修改后重启即可。