今天在學習Docker的時候
使用yum install docker安裝完后啟動不了,報錯如下:
[root@Sakura ~]# service docker start docker: unrecognized service
一直停留在以上步驟,如果有遇到和我一樣類似問題的小伙伴可以按照如下方法進行安裝,即可安裝成功~~
方法一:
先移除docker
[root@Sakura ~]# yum remove docker
再移除docker-selinux(如果你之前有安裝過的話)
[root@Sakura ~]# yum remove docker-selinux
然后修改文件
[root@Sakura ~]# vi /etc/yum.repos.d/docker.repo
直接填入如下內容:
[dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg
然后啟動安裝:
[root@Sakura ~]# yum install docker-engine
作為依賴被安裝: docker-engine-selinux.noarch 0:1.10.2-1.el7.centos
然后啟動docker服務:
[root@Sakura ~]# service docker start
返回如下狀態碼:
Starting cgconfig service: [ OK ]
Starting docker: [ OK ]
即可完美的使docker啟動成功!!!
方法二:
直接用這條命令安裝
[root@Sakura ~]# curl -fsSL https://get.docker.com/ | sh + sh -c 'sleep 3; yum -y -q install docker-engine'
可能會有以下提示信息,我們不需要去管:
警告:/var/cache/yum/x86_64/7/docker-main-repo/packages/docker-engine-selinux-1.10.2-1.el7.centos.noarch.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID 2c52609d: NOKEY docker-engine-selinux-1.10.2-1.el7.centos.noarch.rpm 的公鑰尚未安裝 導入 GPG key 0x2C52609D: 用戶ID : "Docker Release Tool (releasedocker) " 指紋 : 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d 來自 : https://yum.dockerproject.org/gpg setsebool: SELinux is disabled. + sh -c 'docker version' Client: Version: 1.10.2 API version: 1.22 Go version: go1.5.3 Git commit: c3959b1 Built: Mon Feb 22 16:16:33 2016 OS/Arch: linux/amd64 Cannot connect to the Docker daemon. Is the docker daemon running on this host? If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group with something like: sudo usermod -aG docker your-user Remember that you will have to log out and back in for this to take effect!
然后直接啟動就好了~~~
[root@Sakura ~]# service docker start Redirecting to /bin/systemctl start docker.service
