#!/usr/bin/env bash
if [ $# != 3 ] ; then
echo "USAGE: load_image.sh <registry> <name-space> <path/images_tar>"
exit 1;
fi
registry=$1
name_space=$2
images_tar=$3
load_image(){
echo "docker load 解压镜像中。。。"
images=`docker load < ${images_tar} | grep -i "loaded image" | cut -d ' ' -f 3`
echo "Start to tag and push images,please wait some minutes.................."
for image in $images;
do
new_image=`echo ${image} | awk -F '/' '{print ${name_space}/$3}'`
docker tag ${image} ${registry}/${new_image}
echo "开始docker push ${registry}/${new_image}"
docker push ${registry}/${new_image}
echo "结束docker push ${new_image} to ${registry} success"
done
echo "docker push 完成"
}
load_image
网友评论