docker.service 运行 'start' 任务失败:没有那个文件或目录

docker.service failed to run 'start' task: No such file or directory

当我使用此脚本在 CentOS 7.4 上启动 docker 时:

systemctl start docker.service

显示此错误:

[root@ops001 docker]# systemctl start docker.service
JJob for docker.service failed because a configured resource limit was exceeded. See "systemctl status docker.service" and "journalctl -xe" for details.

然后我用这个命令检查docker状态:

systemctl status docker.service -l

它显示我是这样的:

[root@ops001 docker]# systemctl status docker.service -l
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Sun 2020-04-12 21:31:35 CST; 3min 17s ago
     Docs: https://docs.docker.com

Apr 12 21:31:33 ops001.example.com systemd[1]: docker.service failed to run 'start' task: No such file or directory
Apr 12 21:31:33 ops001.example.com systemd[1]: Failed to start Docker Application Container Engine.
Apr 12 21:31:33 ops001.example.com systemd[1]: Unit docker.service entered failed state.
Apr 12 21:31:33 ops001.example.com systemd[1]: docker.service failed.
Apr 12 21:31:35 ops001.example.com systemd[1]: docker.service holdoff time over, scheduling restart.
Apr 12 21:31:35 ops001.example.com systemd[1]: Stopped Docker Application Container Engine.
Apr 12 21:31:35 ops001.example.com systemd[1]: start request repeated too quickly for docker.service
Apr 12 21:31:35 ops001.example.com systemd[1]: Failed to start Docker Application Container Engine.
Apr 12 21:31:35 ops001.example.com systemd[1]: Unit docker.service entered failed state.
Apr 12 21:31:35 ops001.example.com systemd[1]: docker.service failed.

哪里出错了?我应该怎么做才能使 docker 工作?

我正在检查 docker 服务定义文件 vim /usr/lib/systemd/system/docker.service:

[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
EnvironmentFile=/run/docker_opts.env
ExecStart=/usr/bin/dockerd $DOCKER_OPTS -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

使用文件 /run/docker_opts.env,但未在路径中找到该文件。所以使用这个命令生成文件:

/opt/k8s/bin/mk-docker-opts.sh -d /run/docker_opts.env -c

然后使用此命令启动:

systemctl start docker

有效。