Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

View the python script of private repository image

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Download the python interpreter on the python website

[https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz]

two。 Unpack and enter the directory with the same name to compile and install

[root@localhost python] #. / configure-prefix=/usr/local/python3

3. Set the python3 program to soft connection

[root@localhost] # ln-s / usr/local/python3/bin/python3 / usr/bin/python3

4. Create a virtual environment and activate [root@localhost] # mkdir python python3-m venv ~ / python [root@localhost ~] # source python/bin/activate5. Execute a script to view the image

(python) [root@localhost ~] # cat get_images.py

#! / usr/bin/env pythonimport requests import json import traceback repo_ip = '1.1.1.1' repo_port = 5000 def getImagesNames (repo_ip Repo_port): docker_images = [] try: url = "http://" + repo_ip +": "+ str (repo_port) +" / v2/_catalog "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 [' tags'] 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 a=getImagesNames (repo_ip Repo_port) final effect (python) [root@localhost ~] # python get_images.py 1.1.1.1:5000/anmi_web:1.0.21.1.1.1:5000/anmi_web:1.0.31.1.1.1:5000/redis:1.0.21.1.1.1:5000/duyanbase:1.01.1.1.1:5000/duyanbase:latest

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report