美文网首页程序员
先电paas比赛批量加载镜像并推送到仓库

先电paas比赛批量加载镜像并推送到仓库

作者: 南南宫问天 | 来源:发表于2020-04-27 20:24 被阅读0次
[root@server ~]# cat docker_load_push.sh 
#/bin/bash
##Auther czq
##email 2484576482@qq.com
registry=`df -hT | grep "iso9660   5.9G" | awk '{print $NF}'`/images/rancher1.6.5
ip=172.16.210.30 ##定义仓库地址
>/root/load.txt  ##清空存放镜像id文件

df -hT | grep "iso9660   5.9G" &> /dev/null
          [ $? -ne 0 ] && echo "请挂载先电磁盘" && exit 
for a in `ls $registry/rancher*tar` ##把当前目录所有的rancher镜像包显示出来并传给变量a
do 
{
    b=`basename $a` c=${b%.tar} d=${c/_v/:v} e=${d/_ho/:ho} f=${e/-n/\/n} ##对镜像名进行切片操作
    docker load -i $a > /root/load.txt ##解压镜像并把解压的id放在load.txt
    txt=`cat /root/load.txt` q=${txt:24:12} ##通过切片的方式截出镜像id
    docker tag $q  $ip:5000/${f/_/\/} 
    docker push  $ip:5000/${f/_/\/} &> /dev/null
    if [ $? -eq 0 ];then
        echo "push $f compelete"
    else
        echo "push $f false"
    fi
}& ##放在后台
done
wait 
echo -e "\e[1;33mpush compelete \e[0m" 
[root@server ~]# chmod +x docker_load_push.sh  ##赋予执行权限
[root@server ~]# ./docker_load_push.sh  ##执行脚本
push rancher_metadata:v0.9.2 compelete
push rancher_scheduler:v0.8.2 compelete
push rancher_agent:v1.2.5 compelete
push rancher_network-manager:v0.7.4 compelete
push rancher_net:holder compelete
push rancher/net:v0.11.3 compelete
push rancher_dns:v0.15.1 compelete
push rancher_healthcheck:v0.3.1 compelete
push rancher_server:v1.6.5 compelete
push compelete  ##推送完成
[root@server ~]# docker images ##解压也完成
REPOSITORY                                   TAG                 IMAGE ID            CREATED             SIZE
172.16.210.30:5000/rancher/server            v1.6.5              f89070da7581        2 years ago         984.9 MB
172.16.210.30:5000/rancher/scheduler         v0.8.2              690ef14a99b7        2 years ago         241.9 MB
172.16.210.30:5000/rancher/agent             v1.2.5              ef5fea38dbe6        2 years ago         237.1 MB
172.16.210.30:5000/rancher/network-manager   v0.7.4              787fc137ac53        2 years ago         248.8 MB
172.16.210.30:5000/rancher/metadata          v0.9.2              d46f30a656e0        2 years ago         251.5 MB
172.16.210.30:5000/rancher/net               v0.11.3             9495baae8faf        2 years ago         267.3 MB
172.16.210.30:5000/rancher/dns               v0.15.1             af5509fe436b        2 years ago         239.8 MB
172.16.210.30:5000/rancher/healthcheck       v0.3.1              10710b438de7        3 years ago         383.9 MB
172.16.210.30:5000/rancher/net               holder              665d9f6e8cc1        3 years ago         267.2 MB
docker.io/registry                           latest              c9bd19d022f6        3 years ago         33.27 MB

相关文章

网友评论

    本文标题:先电paas比赛批量加载镜像并推送到仓库

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