使用python脚本获取docker私有镜像仓库镜像信息
2017-11-12 12:54
886 查看
方便快速查看仓库中镜像信息
github: https://github.com/charnet1019/get_image_names.py.git
github: https://github.com/charnet1019/get_image_names.py.git
#!/usr/bin/env python #-*- coding:utf-8 -*- ########################################################## # # Copyright (2017-10-21, ) # # Author: charnet1019@163.com # Last modified:2017-10-28 22:00 # Description: # ########################################################## import requests import json import traceback repo_ip = 'registry' repo_port = 5000 COUNT=3000 def isNotEmpty(s): return s and len(s.strip()) > 0 def getImagesNames(repo_ip,repo_port): docker_images = [] try: url = "http://" + repo_ip + ":" + str(repo_port) + "/v2/_catalog?n=" + str(COUNT) res =requests.get(url).content.strip() res_dic = json.loads(res) images_type = res_dic['repositories'] for i in images_type: url2 = "http://" + repo_ip + ":" + str(repo_port) +"/v2/" + str(i) + "/tags/list" res2 =requests.get(url2).content.strip() res_dic2 = json.loads(res2) name = res_dic2['name'] # tags = res_dic2[filter(isNotEmpty,'tags')] tags = res_dic2['tags'] if tags not in [None]: for tag in tags: docker_name = str(repo_ip) + ":" + str(repo_port) + "/" + name + ":" + tag docker_images.append(docker_name) print(docker_name) except: traceback.print_exc() return docker_images if __name__ == '__main__': getImagesNames(repo_ip, repo_port)
相关文章推荐
- 使用Docker registry镜像创建私有仓库
- 使用Python脚本来获取Cisco设备信息的示例
- 获取docker私有仓库中所有镜像的方法
- 使用shell 脚本获取多台docker容器信息
- linux系统使用python获取cpu信息脚本分享
- 使用python编写脚本获取手机当前应用apk的信息
- 使用Harbor搭建Docker私有镜像仓库服务
- linux系统使用python获取内存使用信息脚本分享
- 使用python编写脚本获取手机当前应用的信息
- k8s之使用secret获取私有仓库镜像
- 使用Python脚本来获取Cisco设备信息的示例
- docker获取镜像仓库里所有镜像的脚本
- 使用Dockerfile构建镜像并push到私有仓库
- linux系统使用python获取cpu信息脚本分享
- 使用官方 docker registry 搭建私有镜像仓库及部署 web ui
- 使用 harbor 搭建 docker 私有镜像仓库
- 使用docker registry建立私有镜像仓库
- 使用python编写脚本获取手机当前应用apk的信息
- 使用Harbor搭建Docker私有镜像仓库服务
- 使用Dockerfile构建镜像并push到私有仓库