Recently in the study of Kubernetes,docker warehouse used more, every query has to curl good trouble, so just wrote this.
#!/usr/bin/env python# -*- coding: utf-8 -*-"" "author = ' Perling ' time = ' 2016/11/10 ' "" "import urllib2import jsonregistry=" 172.31.14.229:5000 "registry_url = "http://%s"%registrydef http_get (URL): req = urllib2. Request (URL) req.add_header ("Content-type", "Application/json-rpc") resp = urllib2.urlopen (req) resp_json = json.loads (Resp.read ( )) return resp_jsondef get_repository_list (): data = http_get (registry_url+ "/v2/_catalog") repository_list = data[' Repositories '] return repository_listdef get_repository_tags (repository): data = http_get ("%s/v2/%s/tags/list"% (registry_url,repository)) tags = data[' tags ']&Nbsp; return tagsdef get_all_repository_tags (): data = {} for repositoary in get_repository_list (): data[repositoary]=get_repository_tags (repositoary) return dataif __name__ == ' __main__ ': data = get_all_repository _tags () print "/" print "|" for key in data: print "|--- %s"%key for tag in data[key]: print "| | --- %-15s %s/%s:%s "% (Tag,registry,key,tag)
This article is from the "perling" blog, make sure to keep this source http://zhaolin.blog.51cto.com/9397923/1871550
Format output for all tags and tag links in Docker registry