1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| # 脚本功能 # 从x86镜像仓库拉取x86镜像 # 从arm镜像仓库拉取arm镜像 # 修改tag之后,以manifest的方式传到支持manifest功能的新镜像仓库
docker login xxx -u xxx -p 'xxx'
oldAmdHarbor="xxx" oldArmHarbor="xxx" newHarbor="xxx" images=( # dashboard:v2.5.0 # metrics-scraper:v1.0.9 # coredns:1.8.4 metrics-server:v0.5.2 # pause:3.5 # nginx:1.14.2 # busybox:1.28 # alpine-k8s:3.15.4-v2 ) for image in ${images[@]} do oldAmdHarborImage=$oldAmdHarbor/$image oldArmHarborImage=$oldArmHarbor/$image newHarborImage=$newHarbor/$image newAmdHarborImage=$newHarbor/$image-amd64 newArmHarborImage=$newHarbor/$image-arm64 echo -e "\n########## oldAmdHarborImage ##########" echo $oldAmdHarborImage
echo -e "\n########## oldArmHarborImage ##########" echo $oldArmHarborImage echo -e "\n########## newHarborImage ##########" echo $newHarborImage echo -e "\n########## newAmdHarborImage ##########" echo $newAmdHarborImage echo -e "\n########## newArmHarborImage ##########" echo $newArmHarborImage
echo -e "\n####################### 操作前 #######################" app=`echo $image | cut -d ":" -f 1` echo -e "\n########## docker images |grep $app |grep $newHarbor ##########" docker images |grep $app |grep $newHarbor
echo -e "\n####################### 具体操作 #######################" echo -e "\n########## docker pull $oldAmdHarborImage --platform amd64 ##########" docker pull $oldAmdHarborImage --platform amd64 echo -e "\n########## docker tag $oldAmdHarborImage $newAmdHarborImage ##########" docker tag $oldAmdHarborImage $newAmdHarborImage echo -e "\n########## docker push $newAmdHarborImage ##########" docker push $newAmdHarborImage echo -e "\n########## docker pull $oldArmHarborImage --platform arm64 ##########" docker pull $oldArmHarborImage --platform arm64 echo -e "\n########## docker tag $oldArmHarborImage $newArmHarborImage ##########" docker tag $oldArmHarborImage $newArmHarborImage echo -e "\n########## docker push $newArmHarborImage ##########" docker push $newArmHarborImage echo -e "\n########## docker manifest create $newHarborImage $newAmdHarborImage $newArmHarborImage ##########" docker manifest create $newHarborImage $newAmdHarborImage $newArmHarborImage echo -e "\n########## docker manifest push $newHarborImage ##########" docker manifest push $newHarborImage echo -e "\n########## docker manifest inspect $newHarborImage ##########" docker manifest inspect $newHarborImage
echo -e "\n####################### 操作后 #######################" app=`echo $image | cut -d ":" -f 1` echo -e "\n########## docker images |grep $app |grep $newHarbor ##########" docker images |grep $app |grep $newHarbor done
|