一、旧版本Docker卸载
1、查看已安装的Docker信息
[root@VM_0_7_centos ~]# yum list installed | grep docker
docker.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos @extras
docker-client.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos @extras
docker-common.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos @extras
2、卸载已安装的Docker
yum remove docker docker-client docker-common -y
3、清楚其他残余Docker文件
find /etc/systemd -name '*docker*' -exec rm -f {} \;
find /lib/systemd -name '*docker*' -exec rm -f {} \;
二、安装Docker
yum install docker
三、运行Docker并设置为开机自启
安装完成后,使用下面的命令来启动 docker 服务,并将其设置为开机启动:
[root@localhost ~]# service docker start
[root@localhost ~]# chkconfig docker on
(LCTT 译注:此处采用了旧式的 sysv 语法,如采用CentOS 7中支持的新式 systemd 语法,如下:
[root@localhost ~]# systemctl start docker.service
[root@localhost ~]# systemctl enable docker.service
)
四、查看Docker是否安装成功
[root@VM_0_7_centos ~]# docker version
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64
Go version: go1.10.3
Git commit: b2f74b2/1.13.1
Built: Wed May 1 14:55:20 2019
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64
Go version: go1.10.3
Git commit: b2f74b2/1.13.1
Built: Wed May 1 14:55:20 2019
OS/Arch: linux/amd64
Experimental: false
有client和service两部分表示docker安装启动都成功了