如何在远程注册表上列出 Docker 映像的所有标签? [英] How can I list all tags for a Docker image on a remote registry?
问题描述
如何使用 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 '}' '
' | awk -F: '{print $3}'
<小时>
更新感谢@degelf 的建议.这是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 '}' '
' | awk -F: '{print $3}'`
if [ -n "$2" ]
then
tags=` echo "${tags}" | grep "$2" `
fi
echo "${tags}"
您可以在/usr/local/bin 下创建一个新文件名 dockertags
(或将 PATH env 添加到您的 .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屋!