centos7安装docker环境
2020-11-16 本文已影响0人
拾杉
1、检查系统和内核版本
cat /etc/centos-release
uname -a

2、安装系统依赖工具
yum install -y yum-utils device-mapper-persistent-data lvm2

3、yum的配置管理,添加docker的软件源地址
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、更新yum缓存
yum makecache fast

5、可以查看所有仓库中所有docker版本,并选择特定版本安装
yum list docker-ce --showduplicates | sort -r

6、选择docker版本安装,由于repo中默认只开启stable仓库,这里安装的是最新版本
yum install docker-ce 或者指定版本sudo yum install docker-ce-17.12.1.ce

7、启动docker服务
systemctl start docker
8、加入开机启动项
systemctl enable docker

9、查看docker版本
docker version

10、如果安装出错时:

这个报错是container-selinux版本低或者是没安装的原因
yum 安装container-selinux 一般的yum源又找不到这个包
需要安装epel源 才能yum安装container-selinux
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release #阿里云上的epel源
再安装container-selinux
yum install container-selinux
然后在安装docker-ce就可以了。
yum install docker-ce-18.09.6 docker-ce-cli-18.09.6 containerd.io -y


至此,Docker 引擎的安装就完成了。