kubernetes-handbook/manifests/scripts/pull-rename-push-docker-ima...

14 lines
422 B
Bash
Raw Normal View History

2017-08-01 21:45:05 +08:00
#!/bin/bash
2018-05-04 19:48:54 +08:00
repo=harbor-001.jimmysong.io/library/
2017-08-01 21:45:05 +08:00
cat $1|while read line
do
docker pull $line
old_name=`echo $line|cut -d ":" -f1`
tag=`echo $line|cut -d ":" -f2`
new_name=$repo`echo $old_name|cut -d "/" -f1`-`echo $old_name|cut -d "/" -f2`:$tag
echo "Change $line => $new_name"
id=`docker images|grep $old_name|tr -s " "|cut -d " " -f3`
docker tag $id $new_name
docker push $new_name
done