加速docker 镜像拉取的方式

国内拉取镜像太慢了,做个学习备份~
  1. 列一下谷歌仓库
# google 镜像仓库:
https://gcr.io/google-containers
https://gcr.io/kubernetes-helm
...
  1. docker 使用本地代理
mkidr -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/http-proxy.conf  <<EOF
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:1080"
EOF
systemctl daemon-reload && systemctl restart docker
  1. docker 使用加速器加速
阿里云镜像仓库:
https://cr.console.aliyun.com
华为云镜像仓库:
https://console.huaweicloud.com/swr
学校的加速站点
https://mirrors.nwafu.edu.cn
https://docker.mirrors.ustc.edu.cn
...
  1. 使用云机器去拉取镜像拷贝,导入阿里云私有容器源
# 各类云厂商 / 百度
# 谷歌免费小机器 https://console.cloud.google.com/cloudshell
# https://www.travis-ci.com + github 自动化构建
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker login $ALI_REGISTRY -u $ALI_USERNAME  -p $ALI_PASSWORD
# img-list.txt 需要拉取镜像的列表
for image in $(cat img-list.txt)
do
    image_name=${image##*/}
    docker pull $image
    docker tag $image $DOCKER_HUB/$image_name
    docker tag $image $ALI_REGISTRY/$image_name
    # push到dockerhub
    docker push $DOCKER_HUB/$image_name
    # push到阿里云仓库
    docker push $ALI_REGISTRY/$image_name
done
posted @ 2020-08-18 10:36  运维之爪  阅读(855)  评论(0编辑  收藏  举报