1. First add the official domestic image of docker
sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://registry.docker-cn.co"] } EOF
2. gcr.io image
According to the open source project:
https://github.com/anjia0532/gcr.io_mirror
The author will pull the gcr.io related image down, and then push it to the official docker warehouse. The relevant conversion syntax is as follows:
grammar
gcr.io/namespace/image_name:image_tag # Equivalent to anjia0532/namespace.image_name:image_tag # Special k8s.gcr.io/{image}/{tag} <==> gcr.io/google-containers/{image}/{tag} <==> anjia0532/google-containers.{image}/{tag}
Batch conversion
# replace gcr.io/google-containers/federation-controller-manager-arm64:v1.3.1-beta.1 to real image # this will convert gcr.io/google-containers/federation-controller-manager-arm64:v1.3.1-beta.1 # to anjia0532/google-containers.federation-controller-manager-arm64:v1.3.1-beta.1 and pull it # k8s.gcr.io/{image}/{tag} <==> gcr.io/google-containers/{image}/{tag} <==> anjia0532/google-containers.{image}/{tag} images=$(cat img.txt) #or #images=$(cat <<EOF # gcr.io/google-containers/federation-controller-manager-arm64:v1.3.1-beta.1 # gcr.io/google-containers/federation-controller-manager-arm64:v1.3.1-beta.1 # gcr.io/google-containers/federation-controller-manager-arm64:v1.3.1-beta.1 #EOF #) eval $(echo ${images}| sed 's/k8s\.gcr\.io/anjia0532\/google-containers/g;s/gcr\.io/anjia0532/g;s/\//\./g;s/ /\n/g;s/anjia0532\./anjia0532\//g' | uniq | awk '{print "docker pull "$1";"}' ) # this code will retag all of anjia0532's image from local e.g. anjia0532/google-containers.federation-controller-manager-arm64:v1.3.1-beta.1 # to gcr.io/google-containers/federation-controller-manager-arm64:v1.3.1-beta.1 # k8s.gcr.io/{image}/{tag} <==> gcr.io/google-containers/{image}/{tag} <==> anjia0532/google-containers.{image}/{tag} for img in $(docker images --format "{{.Repository}}:{{.Tag}}"| grep "anjia0532"); do n=$(echo ${img}| awk -F'[/.:]' '{printf "gcr.io/%s",$2}') image=$(echo ${img}| awk -F'[/.:]' '{printf "/%s",$3}') tag=$(echo ${img}| awk -F'[:]' '{printf ":%s",$2}') docker tag $img "${n}${image}${tag}" [[ ${n} == "gcr.io/google-containers" ]] && docker tag $img "k8s.gcr.io${image}${tag}" done
3. Pull Google container tool script
To facilitate the pull container, we can write a shell script to assist:
vim pull-google.sh:
image=$1 echo $1 img=`echo $image | sed 's/k8s\.gcr\.io/anjia0532\/google-containers/g;s/gcr\.io/anjia0532/g;s/\//\./g;s/ /\n/g;s/_/-/g;s/anjia0532\./anjia0532\//g' | uniq | awk '{print ""$1""}'` echo "docker pull $img" docker pull $img echo "docker tag $img $image" docker tag $img $image ~
Then put it in / usr/local/bin
chmod +x pull-google.sh && cp pull-google.sh /usr/local/bin/pull-google-container
You can use the pull Google container command happily
pull-google-container gcr.io/google-samples/gb-frontend:v4 gcr.io/google-samples/gb-frontend:v4 docker pull anjia0532/google-samples.gb-frontend:v4 v4: Pulling from anjia0532/google-samples.gb-frontend Digest: sha256:aaa5b327ef3b4cb705513ab674fa40df66981616950c7de4912a621f9ee03dd4 Status: Image is up to date for anjia0532/google-samples.gb-frontend:v4 docker tag anjia0532/google-samples.gb-frontend:v4 gcr.io/google-samples/gb-frontend:v4
By Jadepeng
Source: jqpeng's technical notebook-- http://www.cnblogs.com/xiaoqi
Your support is the biggest encouragement to the blogger. Thank you for reading carefully.
The copyright of this article belongs to the author, and you are welcome to reprint it. However, without the consent of the author, you must keep this statement, and give the original link in the obvious position of the article page. Otherwise, you are entitled to pursue legal liability.