docker.service无法运行“启动”任务:无此类文件或目录

时间:2020-04-12 13:42:03

标签: docker systemctl

当我使用此脚本在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工作?

1 个答案:

答案 0 :(得分:0)

我正在检查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

有效。