卸载旧版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装配置相关依赖
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/CentOS7/docker-ce.repo
如果你的服务器连接官网超时,可换为阿里云的
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/CentOS7/docker-ce.repo
安装docker引擎
sudo yum install docker-ce docker-ce-cli containerd.io
启动docker
sudo systemctl start docker
设置开机自启动
sudo systemctl enable docker
验证是否正确安装
sudo docker run hello-world
配置阿里云镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://9w9zqgnf.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker