代码改变世界

gcr.io访问异常无法拉取镜像问题【转】

2023-02-02 11:17  方斌  阅读(137)  评论(0编辑  收藏  举报

引用了
zhangguanzhang.gcr.io
https://github.com/zhangguanzhang/gcr.io
自己开源的获取google镜像仓库的办法

详情可查看该文章release
拉取
假设需要拉取gcr.io/google_containers/pause:3.1 和 gcr.io/google_containers/kube-apiserver-amd64:v1.11.3

$ curl -s https://zhangguanzhang.github.io/bash/pull.sh | bash -s -- gcr.io/google_containers/pause:3.1
$ curl -s https://zhangguanzhang.github.io/bash/pull.sh | bash -s -- gcr.io/google_containers/kube-apiserver-amd64:v1.11.3

查询
查询域名仓库下的namespace和namespace里的镜像列表

$ curl -s https://zhangguanzhang.github.io/bash/pull.sh | bash -s search gcr.io
google-samples
google_containers
k8s-minikube
kubernetes-helm
runconduit
spinnaker-marketplace
tf-on-k8s-dogfood
$ curl -s https://zhangguanzhang.github.io/bash/pull.sh | bash -s search gcr.io/google_containers
addon-builder
addon-resizer-amd64
addon-resizer-arm
addon-resizer-arm64
addon-resizer-ppc64le
addon-resizer-s390x
......

查询镜像的所有tag或者是否存在tag时

$ curl -s https://zhangguanzhang.github.io/bash/pull.sh | bash -s -- search gcr.io/google_containers/kube-apiserver-amd64
v1.10.0-alpha.0
v1.10.0-alpha.1
v1.10.0-alpha.2
v1.10.0-alpha.3
v1.10.0-beta.0
......
$ curl -s https://zhangguanzhang.github.io/bash/pull.sh | bash -s -- search gcr.io/google_containers/kube-apiserver-amd64:v1.9.3
v1.9.3

或者自己把内容保存为脚本拉取

方便后期扩展 利用shell的先展开变量这一特点来实现了伪接口扩展来拉取其他仓库

foo(){
    while read img;do
        while read tag;do
            echo docker pull $img:$tag
            echo docker push repo/$img:$tag
        done < <( $@::get_img_tags $img)
    done < <( $@::get_names )
}


google::get_names(){

}

google::get_img_tags(){

}

quay_io::get_names(){

}
quay_io::get_img_tags(){

}


foo google
foo quay_io