官方安装链接(CentOS):https://docs.docker.com/engine/install/centos/

删除之前安装痕迹:

1
2
3
4
5
6
7
8
9
10
11
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine \
docker-ce
1
2
# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
1
2
3
# Step 2: 添加软件源信息,此处使用阿里云,官方链接可能会比较慢
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
1
2
# Step 3: 更新并安装 Docker-CE
sudo yum -y install docker-ce
1
2
3
4
# Step 4关闭防火墙
systemctl stop firewalld
# 禁止开机启动防火墙
systemctl disable firewalld
1
2
3
# Step 5: 开启Docker服务
systemctl start docker
systemctl enable docker

配置镜像加速器(阿里云镜像加速器

1
2
3
4
5
6
7
8
sudo mkdir -p /etc/docker 
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["你的加速器地址"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker