yum remove -y docker \ docker-client \ docker-client-latest \ docker- common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-sqlinux \ docker-engine-selinux \ docker-engine \ docker-ce \ docker-ce-cli
yum-utils 提供 yum-config-manager 功能,另两个是 devicemapper 驱动依赖
yum install -y yum-utils devi ce-mapper-pers istent-data 1vm2 --ski p- broken
yum-config-manager --add-repo http://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 -y docker-ce-版本号(指定版本安装) yum install -y docker-ce(安装最新版)
docker 应用需要用到各种端口,逐一设置比较麻烦,建议直接关闭防火墙
systemctl stop firewalld systemctl disable firewalld sed -i 's/enforcing/disabled/' /etc/selinux/config # 临时 setenforce 0
启动 Docker 并设置开机自启
systemctl start docker systemctl enable docker systemctl status docker
修改 daemon.json 文件
vim /etc/docker/daemon.json
添加以下内容,用于让 Docker 信任私有仓库地址,添加国内加速源,保存退出。
{ "max-concurrent-downloads": 3, "max-concurrent-uploads": 5, "registry-mirrors": [ "https://docker.mirrors.ustc.edu.cn", "https://hub-mirror.c.163.com", "https://registry.docker-cn.com" ] }
重新加载配置信息及重启 Docker 服务。
# 重新加载某个服务的配置文件 sudo systemctl daemon-reload # 重新启动 docker sudo systemctl restart docker