给定标签`latest`,我们想在Docker Hub上找到具有相同图像ID的另一个标签.
以下是如何使用Docker Hub API v2查找repo的所有标记:
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/fluent/fluentd/tags/?page_size=100 | jq
Run Code Online (Sandbox Code Playgroud)
不幸的是,它不包含图像ID,但始终为此键的"null"值:
$ curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/fluent/fluentd/tags/?page_size=100 | jq
{
"count": 36,
"next": null,
"previous": null,
"results": [
...
{
"name": "v0.14.11",
"full_size": 11964464,
"id": 7084687,
"repository": 219785,
"creator": 2923,
"last_updater": 2923,
"last_updated": "2016-12-27T07:16:41.294807Z",
"image_id": null,
"v2": true,
"platforms": [
5
]
}, …Run Code Online (Sandbox Code Playgroud)