docker 开启镜像加速

779 阅读1分钟

由于 docker 默认使用的镜像仓库地址是国外的链接,在使用默认仓库拉取镜像的时候会非常非常的慢,所以就需要用到镜像加速,这里我使用的是阿里云容器镜像服务的镜像加速器

  1. 首先附上阿里云容器镜像服务的链接

    https://cr.console.aliyun.com/cn-shenzhen/instances/repositories
    

    如下图所示

    image-20210127133428855

  2. 在左侧导航栏可以找到 镜像中心 > 镜像加速器,我这里是 centos 系统,所以选择的是 centos

    image-20210127133731468

    1. 按照命令配置加速器即可,命令如下

      $ sudo mkdir -p /etc/docker
      $ sudo tee /etc/docker/daemon.json <<-'EOF'
        {
          "registry-mirrors": ["https://hu9ce09v.mirror.aliyuncs.com"]
        }
        EOF
      $ sudo systemctl daemon-reload
      $ sudo systemctl restart docker
      
    2. 配置结束,再试试 docker pull,会发现拉取镜像的速度快了许多,然后就可以愉快的使用docker了