CentOS7 安装 docker(yum安装)
步骤如下:
一. 如果之前安装过docker先卸载(否则跳过该步骤),如下操作:
yum remove docker docker-common docker-selinux docker-engine
二. 安装需要的软件包
yum-util 提供yum-config-manager功能,另两个是devicemapper驱动依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
三. 设置 docker安装源(选择其一)
阿里仓库:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
中央仓库:
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
步骤三可能遇到的问题:如果换源失败显示如下:
Could not fetch/save url https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to file /
导致的问题有两个,所以解决方法也有两个,看看自己的问题在哪:
第一种情况:
查看是否可以访问网络,如果网络是连接的,但是无法网址,例如无法访问百度,则需要进行DNS配置:
vi /etc/resolv.conf
在页面内添加代码:
nameserver 114.114.114.114
重启网络:
service network restart
第二种情况:
请查看该博主博客 :https://blog.csdn.net/adminxiaofan/article/details/93169129
四. 选择docker
1.查看 docker 版本
yum list docker-ce --showduplicates | sort -r
2.安装想要的版本 (yum install docker-ce-版本号)
yum -y install docker-ce-18.03.1.ce
出现如图表示安装完成:
五. 启动 Docker 并设置开机自启
systemctl start docker
systemctl enable docker