如何在远程注册表上列出Docker映像的所有标签? [英] How can I list all tags for a Docker image on a remote registry?

查看:45
本文介绍了如何在远程注册表上列出Docker映像的所有标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用CLI(首选)或curl在远程Docker注册表上列出Docker映像的所有标签?

How can I list all tags of a Docker image on a remote Docker registry using the CLI (preferred) or curl?

最好不从远程提取所有版本注册表。我只想列出标签。

Preferably without pulling all versions from the remote registry. I just want to list the tags.

推荐答案

我从此处。非常感谢! :)

I got the answer from here . Thanks a lot! :)

只需一行脚本:(找到debian的所有标签)

Just one-line-script:(find all the tags of debian)

wget -q https://registry.hub.docker.com/v1/repositories/debian/tags -O -  | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n'  | awk -F: '{print $3}'






更新
谢谢
这是shell脚本。


UPDATE Thanks for @degelf's advice. Here is the shell script.

#!/bin/bash

if [ $# -lt 1 ]
then
cat << HELP

dockertags  --  list all tags for a Docker image on a remote registry.

EXAMPLE: 
    - list all tags for ubuntu:
       dockertags ubuntu

    - list all php tags containing apache:
       dockertags php apache

HELP
fi

image="$1"
tags=`wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O -  | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n'  | awk -F: '{print $3}'`

if [ -n "$2" ]
then
    tags=` echo "${tags}" | grep "$2" `
fi

echo "${tags}"

您可以在/ usr / local / bin下创建一个新文件名 dockertags (或在中添加PATH环境。 bashrc / .zshrc ),然后将该代码放入其中。
然后添加可执行权限( chmod + x dockertags )。

You can just create a new file name, dockertags, under /usr/local/bin (or add a PATH env to your .bashrc/.zshrc), and put that code in it. Then add the executable permissions(chmod +x dockertags).

用法:

dockertags ubuntu --->列出ubuntu的所有标签

dockertags ubuntu ---> list all tags of ubuntu

dockertags php apache --->列出所有包含'apache'的php标签

dockertags php apache ---> list all php tags php containing 'apache'

这篇关于如何在远程注册表上列出Docker映像的所有标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆