解决在CentOS 7上安装docker后无法启动的问题

Symptoms:

 在CentOS 7 上使用yum安装docker后,无法启动,报:

# service docker start
Redirecting to /bin/systemctl start  docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
通过# 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: exit-code) since Thu 2018-03-22 11:01:13 EDT; 4s ago
     Docs: http://docs.docker.com
  Process: 2948 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 --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
 Main PID: 2948 (code=exited, status=1/FAILURE)
Mar 22 11:01:12 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Mar 22 11:01:12 localhost.localdomain dockerd-current[2948]: time="2018-03-22T11:01:12.114129701-04:00" level=warning msg="could not change g...found"
Mar 22 11:01:12 localhost.localdomain dockerd-current[2948]: time="2018-03-22T11:01:12.118546683-04:00" level=info msg="libcontainerd: new co... 2953"

Mar 22 11:01:13 localhost.localdomain dockerd-current[2948]: 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) 
Mar 22 11:01:13 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Mar 22 11:01:13 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Mar 22 11:01:13 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Mar 22 11:01:13 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

Solutions:

根据高亮的错误日志得知,此linux的内核中的SELinux不支持 overlay2 graph driver ,解决方法有两个,要么启动一个新内核,要么就在docker里禁用selinux,--selinux-enabled=false
重新编辑docker配置文件:
# vim /etc/sysconfig/docker

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi


如上改为--selinux-enabled=false后保存,重启docker,搞定!

你可能感兴趣的:(Docker)