一摊鸡、安裝docker
1.更新yum源,更新到最新(也可不更)
[root@localhost ~]# yum update
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
正在解決依賴關(guān)系
--> 正在檢查事務(wù)
---> 軟件包 bind-libs.x86_64.32.9.9.4-61.el7 將被 升級
---> 軟件包 bind-libs.x86_64.32.9.9.4-61.el7_5.1 將被 更新
---> 軟件包 bind-libs-lite.x86_64.32.9.9.4-61.el7 將被 升級
---> 軟件包 bind-libs-lite.x86_64.32.9.9.4-61.el7_5.1 將被 更新
---> 軟件包 bind-license.noarch.32.9.9.4-61.el7 將被 升級
---> 軟件包 bind-license.noarch.32.9.9.4-61.el7_5.1 將被 更新
...
...
驗(yàn)證中 : 32:bind-license-9.9.4-61.el7.noarch 8/8
更新完畢:
bind-libs.x86_64 32:9.9.4-61.el7_5.1
bind-libs-lite.x86_64 32:9.9.4-61.el7_5.1
bind-license.noarch 32:9.9.4-61.el7_5.1
bind-utils.x86_64 32:9.9.4-61.el7_5.1
完畢蚕冬!
[root@localhost ~]#
2.安裝需要的依賴軟件包免猾,yum-util 提供yum-config-manager功能,另外兩個是devicemapper驅(qū)動依賴的
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
...
3.設(shè)置yum源
[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加載插件:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
4.可以查看所有倉庫所有docker版本囤热,選擇特定版本進(jìn)行安裝
[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
已加載插件:fastestmirror, langpacks
可安裝的軟件包
* updates: centos.ustc.edu.cn
Loading mirror speeds from cached hostfile
* extras: mirrors.aliyun.com
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
...
5.安裝docker猎提,在這里我選擇的是17.12.1.ce
[root@localhost ~]# yum install docker-ce-17.12.1.ce
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
base | 3.6 kB 00:00
docker-ce-stable | 2.9 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
正在解決依賴關(guān)系
--> 正在檢查事務(wù)
---> 軟件包 docker-ce.x86_64.0.17.12.1.ce-1.el7.centos 將被 安裝
--> 正在處理依賴關(guān)系 container-selinux >= 2.9,它被軟件包 docker-ce-17.12.1.ce-1.el7.centos.x86_64 需要
...
6.啟動docker旁蔼,加入開機(jī)啟動
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
7.查看版本是否成功安裝
[root@localhost ~]# docker version
Client:
Version: 17.12.1-ce
API version: 1.35
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:15:20 2018
OS/Arch: linux/amd64
Server:
Engine:
Version: 17.12.1-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:17:54 2018
OS/Arch: linux/amd64
Experimental: false
二锨苏、卸載docker
1.查詢docker安裝過的包
[root@localhost ~]#yum list installed | grep docker
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
docker.x86_64 2:1.13.1-53.git774336d.el7.centos @extras
docker-client.x86_64 2:1.13.1-53.git774336d.el7.centos @extras
docker-common.x86_64 2:1.13.1-53.git774336d.el7.centos @extras
2.卸載安裝包
[root@localhost ~]#yum -y remove docker.x86_64
[root@localhost ~]#yum -y remove docker-client.x86_64
[root@localhost ~]#yum -y remove docker-common.x86_64
3.刪除鏡像、容器等
[root@localhost ~]#rm -rf /var/lib/docker
4.再次檢查docker是否成功卸載
[root@localhost ~]#dokcer
如果沒有搜索到棺聊,那么表示已經(jīng)卸載成功伞租。