首页 > 解决方案 > 获取远程 docker 存储库中编号最高的图像标签

问题描述

如何在远程注册表中远程确定具有最高标签的图像?无需拉下图像并查看它们。我需要它来处理经过身份验证的连接。

标签: dockerrepository

解决方案


我用 Perl 做到了。如此处所示:


tagslist = commands.getstatusoutput("curl -H \"Content-Type:application/json\" -k -s -u <U>:<P> https://docker-registry/v2/myrepo/tags/list")

n=json.dumps(tagslist)
o=json.loads(n)
m=o[1]
t=json.loads(m)
s=t['tags']
highest=-1
for i in s:
 try:
    iTag = int(i)
    if iTag > highest:
      highest=iTag
 except ValueError:
    val = 0

print highest

这对我来说效果很好。Gnu/Linux 上的 Python 2.7


推荐阅读