如果我运行此命令:
$ docker search node
我在终端机上得到了一些结果:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
node Node.js is a JavaScript-based platform for s… 5716 [OK]
mhart/alpine-node Minimal Node.js built on Alpine Linux 363
mongo-express Web-based MongoDB admin interface, written w… 261 [OK]
nodered/node-red-docker Node-RED Docker images. 157 [OK]
iojs io.js is an npm compatible platform original… 126 [OK]
prom/node-exporter 77 [OK]
我的问题是-是否可以使用命令查找第一个结果的所有变体?
我正在寻找像这样的所有图像/标签的列表:
[
"node:4.2",
"node:5.1",
"node:5.3",
"node:5.45",
"node:5.7",
"node:6.2",
"node:7",
"node:8",
"node:9",
// ...
"node:10"
]
答案 0 :(得分:1)
Docker搜索不具有此功能
您可以做的是将简单的curl
命令与jq
结合使用:
https://registry.hub.docker.com/v1/repositories/<NAME>/tags
示例:
curl https://registry.hub.docker.com/v1/repositories/node/tags | jq -r '.[].name'
将返回所有标签:
...
chakracore-8.11
chakracore-8.11.1
chakracore-8.9
chakracore-8.9.4
jessie
onbuild
slim
stretch
wheezy
如果您要获取所有结果的所有标签:
for i in $(docker search --format {{.Name}} node); do
echo "All tag for image : $i"
curl https://registry.hub.docker.com/v1/repositories/$i/tags | jq -r '.[].name'
done
或第一个结果的所有标记:
name=$(docker search --limit 1 --format {{.Name}} node)
curl https://registry.hub.docker.com/v1/repositories/$name/tags | jq -r '.[].name'