docker安装&镜像加速
- 卸载本机自带docker
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
- 安装依赖
yum install -y yum-utils
- 设置docker镜像仓库 (这里用的是阿里的,也可以用官方的
yum-config-manager --add-repo https://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索引
yum makecache fast
- 安装docker
yum install docker-ce docker-ce-cli containerd.io
- 配置docker镜像加速
- 访问阿里云 https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors 镜像工具-镜像加速器
- 根据操作文档配置即可,以centos为例:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://vxxxxaaa.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
当yum配置的是官当的地址时,安装出现报错,参考https://stackoverflow.com/questions/65878769/cannot-install-docker-in-a-rhel-server处理