#encoding:utf8
import os

S_registry = 'registry.cn-hangzhou.aliyuncs.com/bubblelin/'
D_registry = 'k8s.gcr.io/'

master_image = ['kube-apiserver:v1.12.0','kube-controller-manager:v1.12.0',
                'kube-scheduler:v1.12.0','kube-proxy:v1.12.0','flannel:v0.12.0-amd64','pause:3.1',
                'etcd:3.2.24','coredns:1.2.2']

def PullImage(registry,images):
    print("一共%s个镜像" %(len(images),))
    index = 1
    for image in images:
        print("开始下载第[%d]个镜像 ---> [%s]" %(index,image))
        cmd = "docker pull " + registry + image
        os.system(cmd)
        print("done!")
        index +=1

def TagImage(sregistry,dregistry,images):
    print("一共%s个镜像" %(len(images),))
    index = 1 
    for image in images:
        print("开始tag第[%d]个镜像 ---> [%s]  --->[%s]" %(index,sregistry+image,dregistry+image))
        cmd = "docker tag " + sregistry+image + " " +  dregistry + image
        os.system(cmd)
        print("done!")
        index +=1

if __name__ == '__main__':
    # 先执行PullImage,再执行Tag修改源    
    PullImage(S_registry,master_image)
    #TagImage(S_registry,D_registry,master_image)

另外其他的Docker镜像拉取和修改总结可参考:

https://www.cnblogs.com/hongdada/p/11395200.html

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐