概述
整理记录在centos7安装docker时遇到的坑
我的安装步骤:
- 参考了docker官网的安装步骤 https://docs.docker.com/install/linux/docker-ce/centos/
- 安装好了docker之后,美滋滋地执行“systemctl start docker”服务时,报错
“Failed to get D-Bus connection: Operation not permitted”
这个问题比较简单,网上查一查发现一是因为systemctl需要特定的权限,在运行新的容器时增加 “--privileged=true” 参数,参考: https://blog.51cto.com/lizhenliang/1975466
- 再次重复了以上的安装步骤后,再一次美滋滋地执行“systemctl start docker”,依然报同样的错。。。继续google,参考:https://yhz61010.iteye.com/blog/2352597,systemctl终于可以用了,但是有别的错,不要烦躁。。。
[root@9455e87ab6d3 /]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Mon 2019-07-01 19:28:58 CST; 1s ago
Docs: https://docs.docker.com
Process: 443 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 443 (code=exited, status=1/FAILURE)Jul 01 19:28:56 9455e87ab6d3 systemd[1]: Failed to start Docker Application Container Engine.
Jul 01 19:28:56 9455e87ab6d3 systemd[1]: Unit docker.service entered failed state.
Jul 01 19:28:56 9455e87ab6d3 systemd[1]: docker.service failed.
Jul 01 19:28:58 9455e87ab6d3 systemd[1]: docker.service holdoff time over, scheduling restart.
Jul 01 19:28:58 9455e87ab6d3 systemd[1]: Stopped Docker Application Container Engine.
Jul 01 19:28:58 9455e87ab6d3 systemd[1]: start request repeated too quickly for docker.service
Jul 01 19:28:58 9455e87ab6d3 systemd[1]: Failed to start Docker Application Container Engine.
Jul 01 19:28:58 9455e87ab6d3 systemd[1]: Unit docker.service entered failed state.
Jul 01 19:28:58 9455e87ab6d3 systemd[1]: docker.service failed.
似乎没能明显的看出来是什么问题,纠结了老半天,我把“/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock”抠出来单独执行了,结果:
Failed to load listeners: no sockets found via socket activation: make sure the service was started by systemd
看样子是要在systemctl里来执行的,后来发现“/run/containerd/containerd.sock”是个空文件,于是找到docker.socket文件,修改docker.service:
再执行“systemctl start docker”,这时报错信息变了:
[root@989f9e9bc417 /]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2019-07-03 15:31:28 CST; 301ms ago
Docs: https://docs.docker.com
Process: 1443 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/usr/lib/systemd/system/docker.socket (code=exited, status=1/FAILURE)
Main PID: 1443 (code=exited, status=1/FAILURE)Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.971866900+08:00" level=error msg="[graphdriver] prior storage driver devicemapper failed: exec: "mkfs.ext4": exec...und in $PATH"
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.971891500+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.971992000+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.972096100+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.972143600+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.972184000+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.972223900+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.972267700+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: Error starting daemon: error initializing graphdriver: exec: "mkfs.ext4": executable file not found in $PATH
Jul 03 15:31:29 989f9e9bc417 dockerd[1443]: time="2019-07-03T15:31:28.972307200+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in Transient...
Hint: Some lines were ellipsized, use -l to show in full.
宿主机重启一下再执行,报错信息里有这么一条:
Error starting daemon: error initializing graphdriver: exec: "mkfs.ext4": executable file not found in $PATH
缺少mkfs.ext4命令,安装一个,执行
yum install -y e4fsprogs
可以启动了,美滋滋
可能遇到的其它问题:
- 问题1
Jul 03 18:14:34 4c6ad43edf4a dockerd[1463]: time="2019-07-03T18:14:34.440215500+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection err
Jul 03 18:14:34 4c6ad43edf4a dockerd[1463]: time="2019-07-03T18:14:34.440281600+08:00" level=error msg="failed to get event" error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection err
Jul 03 18:14:34 4c6ad43edf4a dockerd[1463]: time="2019-07-03T18:14:34.440613100+08:00" level=error msg="[graphdriver] prior storage driver devicemapper failed: loopback attach failed"
Jul 03 18:14:34 4c6ad43edf4a dockerd[1463]: Error starting daemon: error initializing graphdriver: loopback attach failed
Jul 03 18:14:36 4c6ad43edf4a systemd[1]: docker.service holdoff time over, scheduling restart.
Jul 03 18:14:36 4c6ad43edf4a systemd[1]: Stopped Docker Application Container Engine.
还没找到解决办法,改用ubuntu 了。。。。
最后
以上就是想人陪香氛为你收集整理的centos7安装docker的全部内容,希望文章能够帮你解决centos7安装docker所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复