1. Docker 要求 CentOS 系统的内核版本高于 3.10 ,验证你的CentOS 版本是否支持 Docker ```bash # uname -a Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux ``` 2. 更新 yum ```bash # yum update # yum install -y yum-utils device-mapper-persistent-data lvm2 ``` 3. 安装依赖包 ```bash # yum install -y yum-utils device-mapper-persistent-data lvm2 ``` 4. 配置yum 源 ```bash # yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ``` 5. 列出可安装docker版本 ```bash # yum list docker-ce --showduplicates | sort -r ```  6. 安装,此处我选择安装 17.12.1.ce 版本 ```bash # yum -y install docker-ce-17.12.1.ce ``` 此时出现如下报错 ```bash 2:container-selinux-2.68-1.el7.noarch: [Errno 256] No more mirrors to try ``` 应该是因为没有安装 container-selinux 尝试安装 container-selinux ```bash # yum -y install container-selinux ``` 此时还是无法安装 container-selinux,报错信息忘记截图了 尝试rpm安装 ```bash # wget http://www.rpmfind.net/linux/centos/7.6.1810/extras/x86_64/Packages/container-selinux-2.68-1.el7.noarch.rpm # rpm -ivh container-selinux-2.68-1.el7.noarch.rpm ``` 此时仍是安装失败,但是出现提示信息,大概是说没有安装`policycoreutils-python`这个包,接下来就先安装这个包之后再安装`container-selinux` ```bash # yum -y install policycoreutils-python # yum -y install container-selinux ``` 终于安装成功了,此时再安装docker ```bash # yum install docker-ce-17.12.1.ce ``` 7. 启动docker ```bash # systemctl start docker ``` 8. 设置开机启动 ```bash # systemctl enable docker ``` 9. 检查docker是否安装成功 ```bash # docker version ```  10.参考 https://www.cnblogs.com/yufeng218/p/8370670.html 最后修改:2019 年 08 月 21 日 11 : 15 AM © 著作权归作者所有