1.卸载已有Docker
yum remove docker docker-common docker-selinux docker-engine
2.安装wget后面会用
yum install wget
3.配置yum源
注意,yum源文件在/etc/yum.repos.d,改源之前一定要备份原来的源
cd /etc/yum.repos.d mkdir back mv ./*.repo back #下面配置的是阿里云源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 清除yum缓存 yum clean all # 缓存阿里云源 yum makecache # 测试阿里云源 yum list
4.更新 yum 包
yum -y update
5.安装需要的软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
6.设置yum源
设置一个yum源,下面两个都可用
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(阿里仓库)
7.docker安装
yum -y install docker-ce
8.开启docker并查看版本
systemctl start docker dockcer version
9.安装compose
yum -y install python3-pip pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple pip3 install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose version
10.docker pull镜像加速配置
docker pull失败进行配置
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<EOF { "registry-mirrors": [ "https://docker.registry.cyou", "https://docker-cf.registry.cyou", "https://dockercf.jsdelivr.fyi", "https://docker.jsdelivr.fyi", "https://dockertest.jsdelivr.fyi", "https://mirror.aliyuncs.com", "https://dockerproxy.com", "https://mirror.baidubce.com", "https://docker.m.daocloud.io", "https://docker.nju.edu.cn", "https://docker.mirrors.sjtug.sjtu.edu.cn", "https://docker.mirrors.ustc.edu.cn", "https://mirror.iscas.ac.cn", "https://docker.rainbond.cc" ], "insecure-registries": ["0.0.0.0/0"], "iptables": false } EOF sudo systemctl daemon-reload sudo systemctl restart docker
11.测试
docker run --rm hello-world
标签:repo,compose,centos7,etc,yum,install,docker From: https://www.cnblogs.com/kenmeon/p/18460622