CentOS7 配置Docker 阿里云镜像加速

镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。国内很多云服务商都提供了国内加速器服务,例如:

  • Azure 中国镜像 https://dockerhub.azk8s.cn
  • (需登录账号获取)阿里云加速器(个人)https://oalqrqxl.mirror.aliyuncs.com
  • 七牛云加速器 https://reg-mirror.qiniu.com

配置阿里云加速器 

CentOS7 配置Docker 阿里云镜像加速_第1张图片

1. 安装/升级Docker客户端 

推荐安装1.10.0以上版本的Docker客户端

2. 配置阿里云个人镜像加速器

针对Docker客户端版本大于 1.10.0 的用户

您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://oalqrqxl.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

MobaXterm实际操作:

[root@localhost etc]# sudo mkdir -p /etc/docker
[root@localhost etc]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://oalqrqxl.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://oalqrqxl.mirror.aliyuncs.com"]
}
[root@localhost etc]# sudo systemctl daemon-reload
[root@localhost etc]# sudo systemctl restart docker
[root@localhost etc]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since 三 2022-06-15 09:59:55 CST; 30s ago
     Docs: https://docs.docker.com
 Main PID: 18158 (dockerd)
    Tasks: 17
   Memory: 25.8M
   CGroup: /system.slice/docker.service
           ├─18158 /usr/bin/dockerd
           └─18163 docker-containerd --config /var/run/docker/containerd/cont...

6月 15 09:59:54 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:54 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:54 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:54 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:55 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:55 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:55 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:55 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
6月 15 09:59:55 localhost.localdomain systemd[1]: Started Docker Application...
6月 15 09:59:55 localhost.localdomain dockerd[18158]: time="2022-06-15T09:59...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost etc]#

你可能感兴趣的:(系统架构,CentOS,随手笔记,docker,阿里云,容器)