首页 > 编程语言 > 详细

Python Docker 查看私有仓库镜像【转】

时间:2019-04-04 21:48:49      阅读:114      评论:0      收藏:0      [点我收藏+]

 

文章来源:python Docker 查看私有仓库镜像

 

pip 安装:

# 首先安装epel扩展源:
yum -y install epel-release
# 更新完成之后,就可安装pip:
yum -y install python-pip
# 安装完成之后清除cache:
yum clean all

 

request模块安装:

pip install request

 

get.py 脚本:

 1 #!/usr/bin/env python
 2 #-*- coding:utf-8 -*-
 3 
 4 import requests  
 5 import json  
 6 import traceback  
 7    
 8 repo_ip = 192.168.0.153  
 9 repo_port = 5000  
10    
11 def getImagesNames(repo_ip,repo_port):  
12     docker_images = []  
13     try:  
14         url = "http://" + repo_ip + ":" +str(repo_port) + "/v2/_catalog"  
15         res =requests.get(url).content.strip()  
16         res_dic = json.loads(res)  
17         images_type = res_dic[repositories]  
18         for i in images_type:  
19             url2 = "http://" + repo_ip + ":" +str(repo_port) +"/v2/" + str(i) + "/tags/list"  
20             res2 =requests.get(url2).content.strip()  
21             res_dic2 = json.loads(res2)  
22             name = res_dic2[name]  
23             tags = res_dic2[tags]  
24             for tag in tags:  
25                 docker_name = str(repo_ip) + ":" + str(repo_port) + "/" + name + ":" + tag  
26                 docker_images.append(docker_name)  
27                 print docker_name  
28     except:  
29         traceback.print_exc()  
30     return docker_images  
31    
32 a=getImagesNames(repo_ip, repo_port)  
33 #print a  

 

Python Docker 查看私有仓库镜像【转】

原文:https://www.cnblogs.com/zhanglianghhh/p/10656982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!