阿里云YUM源配置方法
1.先将/etc/yum.repos.d/CentOS-Base.repo 中的文件备份一个(待会会重新下载一次的)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 运行 yum makecache 生成缓存
yum makecache
centos-7 联网安装docker
- 卸载旧版
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 \
device-mapper-persistent-data \
lvm2
- 设置 yum 仓库地址一个是官方的一个是阿里云的
#sudo yum-config-manager \
# --add-repo \
# https://download.docker.com/linux/centos/docker-ce.repo
#建议阿里云
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- 更新 yum 缓存
sudo yum makecache fast
- 安装新版 docker
sudo yum install docker-ce docker-ce-cli containerd.io
- 启动 docker
sudo systemctl restart docker
- 设置 docker 开机启动
sudo systemctl enable docker
- 运行 hello-world 镜像,验证 docker(这里可能报错不要急是因为网速的问题,看第9步)
sudo docker run hello-world
- 镜像加速修改
vim /etc/docker/daemon.json
添加
{
"registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"]
}
- 是修改生效
sudo systemctl daemon-reload
- 重新启动docker服务
sudo systemctl restart docker
12.重新验证hello-world
sudo docker run hello-world
成功就如下图:
参考文章:
阿里云开发社区
docker 安装完成后测试hello-world出现问题
CentOS – 配置docker官方源并用yum安装docker