如何使用 CLI(首选)或 curl 列出远程 Docker 注册表上 Docker 镜像的所有标签?
最好不要从远程注册表中提取所有版本。我只想列出标签。
最佳答案
更新:很遗憾,这个解决方案将不再有效,因为 Docker 有 deprecated the v1 API .
我从 here 得到了答案.非常感谢! :)
一行脚本:(找到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}'
更新 感谢@degelf 的建议。 这是shell脚本。
#!/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
)。
用法:
dockertags ubuntu
--->列出ubuntu的所有标签
dockertags php apache
---> 列出所有包含 'apache' 的 php 标签 php
关于docker - 如何列出远程注册表上 Docker 镜像的所有标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28320134/