一、環境
- registry倉庫:192.168.4.38:5000
- harbor倉庫:https:im.harbor.mobi:4443(https)
- docker: 19.03.2
- docker-compose: 1.22
二、遷移
1、安裝工具
# yum install -y jq
2、harbor中創建項目
名稱自定義,本次實例項目名為romi
image.png
3、登錄
# docker login https:im.harbor.mobi:4443
Username:
Password:
Login Succeeded
4、遷移腳本
#!/bin/bash
images=`curl -s -u test:test 192.168.4.38:5000/v2/_catalog | jq .repositories[] | tr -d '"'`
for image in $images;
do
tags=`curl -s -u test:test 192.168.4.38:5000/v2/$image/tags/list | jq .tags[] | tr -d '"'`
for tag in $tags;
do
docker pull 192.168.4.38:5000/$image:$tag
docker tag 192.168.4.38:5000/$image:$tag im.harbor.mobi:4443/romi/$image:$tag
docker push im.harbor.mobi:4443/romi/$image:$tag
if [ $? -eq 0 ];then
echo "###############################$image:$tag pull complete!###############################"
else
echo "$image:$tag pull failure!"
fi
done
done
5、執行腳本
# sh harbor.sh
# 會有打印日志提示喲
6、查看
image.png
至此,遷移完成!