docker镜像转存脚本

#需要有外网服务器!!!

#!/bin/bash
echo -e "\E[0;41m 私有仓库需要提前登录!! \E[0m \n"

checkEv() {
if [ $1 == 0 ];
then
  echo -e "\E[0;42m 成功 !!!! \E[0m \n"
else
  echo -e "\E[0;41m 失败 !!! \E[0m \n"
fi
}


imagePath=$1
#替换为自己的镜像仓库地址
aliImagePath="registry.cn-chengdu.aliyuncs.com/gcriosa"
imageVersion=`echo ${imagePath} | awk -F\/ '{print $NF}'`

echo -e "\E[0;42m 拉取镜像 !!!! \E[0m \n"
docker pull ${imagePath}
checkEv $?

echo -e "\E[0;42m 镜像路径转换 !!!! \E[0m \n"
docker tag ${imagePath} ${aliImagePath}/${imageVersion}
checkEv $?

echo -e "\E[0;42m 上传到私有仓库 !!!! \E[0m \n"
docker push ${aliImagePath}/${imageVersion}
checkEv $?


echo -e "\E[0;41m 清理镜像!!! \E[0m"
docker rmi ${imagePath}
checkEv $?
docker rmi ${aliImagePath}/${imageVersion}
checkEv $?
posted @   炒鸡蛋  阅读(42)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示