Docker容器

CentOS7安装docker无法启动的问题解决

2018-08-03  本文已影响8人  lunabird

今天在服务器上安装docker时遇到一些问题。

第一步:yum安装docker;

yum install docker

启动docker;

systemctl start docker

到这里的时候就报错了,错误信息如下:

[huangpeng@centos-linux ~]$ sudo 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 -l docker.service

这个命令,加了-l参数是因为不加字符显示不全。然后看到:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 五 2018-08-03 15:31:27 HKT; 3min 2s ago
     Docs: http://docs.docker.com
  Process: 29122 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 --init-path=/usr/libexec/docker/docker-init-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: 29122 (code=exited, status=1/FAILURE)

8月 03 15:31:25 centos-linux.shared systemd[1]: Starting Docker Application Container Engine...
重点是下面这一句:
8月 03 15:31:25 centos-linux.shared dockerd-current[29122]: time="2018-08-03T15:31:25.721701961+08:00" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
8月 03 15:31:25 centos-linux.shared dockerd-current[29122]: time="2018-08-03T15:31:25.725025504+08:00" level=info msg="libcontainerd: new containerd process, pid: 29127"
8月 03 15:31:27 centos-linux.shared dockerd-current[29122]: 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)
8月 03 15:31:27 centos-linux.shared systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
8月 03 15:31:27 centos-linux.shared systemd[1]: Failed to start Docker Application Container Engine.
8月 03 15:31:27 centos-linux.shared systemd[1]: Unit docker.service entered failed state.
8月 03 15:31:27 centos-linux.shared systemd[1]: docker.service failed.

could not change group /var/run/docker.sock to docker: group docker not found说明没有docker这个用户组,然后谷歌一下,发现需要自己创建用户组,于是。

sudo groupadd docker
sudo usermod -aG docker $(whoami)
先退出一下再重新登录来保证有了正确的权限
sudo service docker start

然后再启动,又报了错,不过这次不一样了

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)

意思是说:此linux的内核中的SELinux不支持 overlay2 graph driver ,解决方法有两个,要么启动一个新内核,要么就在docker里禁用selinux,--selinux-enabled=false.
重新编辑docker配置文件:
vi /etc/sysconfig/docker
改为:--selinux-enabled=false


image.png

再次启动一下docker,就好了。

上一篇下一篇

猜你喜欢

热点阅读