Format output for all tags and tag links in Docker registry

Source: Internet
Author: User
Tags docker registry

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.