Search code examples
dockersystemctl

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


When I using this script to start docker on CentOS 7.4:

systemctl start docker.service

It shows this error:

[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.

Then I use this command to check docker status:

systemctl status docker.service -l

It show me like this:

[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.

where is going wrong? What should I do to make docker work?


Solution

  • I am check the docker service define file 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
    

    that using file /run/docker_opts.env, but do not find the file in the path. so using this command to generate the file:

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

    then using this command to start:

    systemctl start docker
    

    works.