docker 推送tar包到远程仓库

tar 包 推送到远程仓库的步骤

  • - 导入镜像(docker load -i 镜像名称)
    
      示例:docker load -i yiyi-admin.tar
    
    - 打标签(docker tag 镜像id registry.cn-hangzhou.aliyuncs.com/空间名称/镜像名称:版本号)
    
      示例:docker tag $image_id registry.cn-hangzhou.aliyuncs.com/yiyi/yiyi-admin:20231130
    
    - 推送到远程仓库(docker push registry.cn-hangzhou.aliyuncs.com/zheng0202/空间名称/镜像名称:版本号)
    
      示例:docker push registry.cn-hangzhou.aliyuncs.com/yiyi/yiyi-admin:20231130
    

完整shell 脚本

#!/bin/bash
echo "---------start---------"
#导入镜像
docker load -i ${1}.tar
enter=$1
#输出镜像名称
echo $enter

image_id=`sudo docker images | grep ${enter%_v*} | awk -F" " '{print $3}' | head -n 1`
image_name=`sudo docker images | grep ${enter%_v*} | awk -F" " '{print $1,$3}'`
#输出镜像id,镜像名称
echo "imageName----" $image_name
echo "imageId-----" $image_id

sleep 5

#打标签
sudo docker tag $image_id registry.cn-hangzhou.aliyuncs.com/yiyi/yiyi-admin:${enter%_v*}-${enter#*_v}
#推送到远程仓库
docker push registry.cn-hangzhou.aliyuncs.com/yiyi/yiyi-admin:${enter%_v*}-${enter#*_v}

echo "---------end---------"

你可能感兴趣的:(docker,eureka,容器)