注意systemctl status docker后的报错信息
第一种
Oct 25 09:18:31 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Oct 25 09:18:31 localhost.localdomain dockerd-current[12137]: time="2018-10-25T09:18:31.425321071+08:00" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
Oct 25 09:18:31 localhost.localdomain dockerd-current[12137]: time="2018-10-25T09:18:31.442651147+08:00" level=info msg="libcontainerd: new containerd process, pid: 12149"
Oct 25 09:18:32 localhost.localdomain dockerd-current[12137]: time="2018-10-25T09:18:32.466837796+08:00" level=warning msg="overlay2: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype...
Oct 25 09:18:32 localhost.localdomain dockerd-current[12137]: Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel or disable selinux in docker (--selinux-enabled=false)
Oct 25 09:18:32 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Oct 25 09:18:32 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Oct 25 09:18:32 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Oct 25 09:18:32 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
解决方式:修改docker配置文件:vim /etc/sysconfig/docker
把OPTIONS一行改为:OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
再启动:systemctl start docker 就可以了
第二种
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2017-07-03 10:12:16 CST; 5s ago
Docs: http://docs.docker.com
Process: 16172 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
Main PID: 16172 (code=exited, status=1/FAILURE)
Jul 03 10:12:15 ALY-HKC-PRO-001 systemd[1]: Starting Docker Application Container Engine...
Jul 03 10:12:15 ALY-HKC-PRO-001 dockerd-current[16172]: time="2017-07-03T10:12:15.812330534+08:00" level=info msg="libcontainerd: new containerd process, pid: 16180"
Jul 03 10:12:16 ALY-HKC-PRO-001 dockerd-current[16172]: time="2017-07-03T10:12:16.823237678+08:00" level=warning msg="devmapper: Usage of loopback devices is strongly discourage...v section."
Jul 03 10:12:16 ALY-HKC-PRO-001 dockerd-current[16172]: time="2017-07-03T10:12:16.838204058+08:00"
level=error msg="[graphdriver] prior storage driver \"devicemapper\" failed: d...run failed"
Jul 03 10:12:16 ALY-HKC-PRO-001 dockerd-current[16172]: time="2017-07-03T10:12:16.838278116+08:00" level=fatal msg="Error starting daemon: error initializing graphdriver: devmap...run failed"
Jul 03 10:12:16 ALY-HKC-PRO-001 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jul 03 10:12:16 ALY-HKC-PRO-001 systemd[1]: Failed to start Docker Application Container Engine.
Jul 03 10:12:16 ALY-HKC-PRO-001 systemd[1]: Unit docker.service entered failed state.
Jul 03 10:12:16 ALY-HKC-PRO-001 systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
此处它提示是Failed to start Docker Application Container Engine。此处关注一下错误,具体的报错信息相同。从其他地方拷贝而来。
解决方案
由于docker的engine 基于Device Mapper提供的一种存储驱动,而它又依赖与 devicemapper。于是乎我将它给删除并重启服务,解决了docker无法正常启动的问题。
# rm -rf /var/lib/docker/
# 添加如下内容
# vim /etc/docker/daemon.json#如果没有 自行创建
{
"graph": "/mnt/docker-data",
"storage-driver": "overlay"
}
以上是具体解决docker安装启动服务的过程。如果有不对的地方,还请指正。近期在写代码做项目整合的时候遇到了需要手工配置的情况,搭建一个docker环境,因此进行了安装测试。