Openstack-实践1.如何从Docker Hub 批量获取某个Open Stack 版本镜像?
思路: 1.获取每个版本与哪些module,每个module里面有哪些组件。 2.对每个组件使用dokcer pull下载。 3.给镜像打tag 4.dokcer push 制作本地镜像仓库。 #前提需要下载kolla的源码到本地/root/下面 #参考标本: abspath=/root/kolla/docker rocky_file=/root/rocky.txt result_file=/root/result.txt tag=rocky namespace=kolla kolla_base_distro=centos kolla_install_type=binary #获取image name function query_kolla_rocky_image_name(){ second_path=($(ls -l $abspath | grep "^d" | awk '{print $NF}')) for element in ${second_path[@]} do #echo $element element_module=($(ls -l $abspath/$element | grep "^d" | awk '{print $NF}')) if [ ${#element_module[@]} -eq 0 ] then echo "$ element has no children" echo $element >> $rocky_file else ls -l $abspath/$element | grep "^d" | awk '{print $NF}' >> $rocky_file fi done } # 下载image并上传到仓库中 function make_registry(){ elements=$(cat $rocky_file) for element in ${elements[@]} do echo $namespace/$kolla_base_distro-$kolla_install_type-$element:$tag docker pull $namespace/$kolla_base_distro-$kolla_install_type-$element:$tag if [ $? -ne 0 ] then echo $namespace/$kolla_base_distro-$kolla_install_type-$element:$tag not exist! >> $result_file else docker tag $namespace/$kolla_base_distro-$kolla_install_type-$element:$tag 192.168.3.103:4000/$namespace/$kolla_base_distro-$kolla_install_type-$element:$tag docker push 192.168.3.103:4000/$namespace/$kolla_base_distro-$kolla_install_type-$element:$tag echo $namespace/$kolla_base_distro-$kolla_install_type-$element:$tag push down! >> $result_file fi done } rm -rf $result_file $rocky_file query_kolla_rocky_image_name make_registry
也可以关注微信公众号:启航学城,干货满满,扫码关注:
也欢迎加入OpenStack技术交流群,进行技术交流。