Docker环境搭建及镜像加速
服务器:阿里云轻量应用服务器
操作系统:Centos7.3
centos的yum换源
1、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
-
Centos 5
-
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
-
-
Centos 6
-
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
-
-
Centos 7
-
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
-
3、运行 yum makecache生成缓存
4、更新系统
yum update -y
安装docker
-
1、卸载旧版本
$ sudo yum remove docker docker-common docker-selinux docker-engine
-
2、安装需要的软件包
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
-
3、安装docker
sudo yum install docker-ce
-
4、启动并加入开机启动
$ sudo systemctl start docker
$ sudo systemctl enable docker
-
5、验证
$ docker version
Docker镜像换源
由于使用的是阿里云服务器,阿里云提供了容器镜像服务,因此使用阿里云的容器镜像服务,具体配置见文档:
https://cr.console.aliyun.com/cn-beijing/instances/mirrors
Docker制作镜像时换源
Alpine:
RUN echo "http://mirrors.aliyun.com/alpine/v3.9/main/" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.9/community/" >> /etc/apk/repositories \