美文网首页
docker 解压镜像包及上传到仓库脚本文件

docker 解压镜像包及上传到仓库脚本文件

作者: for笑 | 来源:发表于2022-02-28 20:52 被阅读0次
    #!/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
    

    相关文章

      网友评论

          本文标题:docker 解压镜像包及上传到仓库脚本文件

          本文链接:https://www.haomeiwen.com/subject/ywlhrrtx.html