我使用的
systemctl restart docker
启动的docker,然后报错
5月 26 11:56:33 localhost.localdomain systemd[1]: Job docker.service/start failed with result 'dependency'.
5月 26 11:58:10 localhost.localdomain systemd[1]: Dependency failed for Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is dependency.
上面这个报错,网上有很多种可能,有的比如是加入要加docker用户组。
我的报错原因有的不一样,就是我可能之前安装过docker,有点残留文件夹,导致systemctl服务启动异常,就是 /usr/lib/systemd/system 目录下多出来一个 docker.service.d 文件夹(里面的启动路径等很多参数都不对),我们知道这个 .d的文件夹配置启动优先级高于普通的 .service文件,相当于是之前安装的docker影响了我当前安装的docker服务启动,我把那个文件夹删就正常了
后记
后来又遇到了别的问题,就是我service启动文件是对的,但是还是报错
6月 01 16:36:41 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
6月 01 16:36:41 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
6月 01 16:36:41 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
6月 01 16:36:41 localhost.localdomain systemd[1]: docker.service failed.
我不得不吐槽这个提示也太模糊了,于是我手动输入了service文件中启动docker的命令
/usr/bin/dockerd -H fd://
然后提示才比较有效,提示
unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [fd://], from file: [tcp://0.0.0.0:2376 unix:///var/run/docker.sock])
就是我有个json里指定了host,然后service命令也指定了host,导致冲突,去掉一个即可