1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#-*- coding:utf-8 -*-
#!/usr/bin/env python
'''
Created on 2016.10.8
@desc: delete images from repo
'''
import requests
repo_ip = "172.16.4.254"
repo_port = 5000
image_name = "oa"
image_tag = "20161012"
def deleteImagesFromRepo(repo_ip,repo_port,image_name,image_tag):
head = {'Accept': 'application/vnd.docker.distribution.manifest.v2+json'}
reg = "http://" + repo_ip + ":" + str(repo_port) + "/v2/"
res = requests.get(reg + image_name + "/manifests/" + image_tag,headers=head,verify=False)
manifest = res.headers['Docker-Content-Digest']
res2 = requests.delete(reg + image_name + "/manifests/"+manifest,verify=False)
if res2.status_code == 202:
print "delete %s success......"%(image_name+':'+image_tag)
else:
print "delete %s fail......"%(image_name+':'+image_tag)
deleteImagesFromRepo(repo_ip,repo_port,image_name,image_tag)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)