删除旧的docker
yum update
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine docker-ce -y
删除旧的docker文件
rm -rf /var/lib/docker
如果无法删除
[root@test docker]# rm -rf containers
rm: 无法删除"containers": 设备或资源忙
umount /var/lib/docker/containers/
rm -rf containers
安装所需要的依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2
安装仓库地址
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
此处可能因为墙的问题出现超时报错,我们改用阿里源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
查看仓库内可选的版本包
yum list docker-ce --showduplicates | sort -r
选则其中一个包安装
yum install docker-ce-18.06.1.ce -y
启动docker 查看docker的运行的状态
[root@test ~]# systemctl start docker
[root@test ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since 三 2019-10-30 17:12:13 CST; 19s ago
Docs: https://docs.docker.com