从第三方回购中检索Docker图像标签
对于直接来自Docker Hub的Docker图像,我可以通过点击它们的存储库API来检索图像的当前标记列表。例如,从第三方回购中检索Docker图像标签,docker,docker-registry,docker-api,Docker,Docker Registry,Docker Api,对于直接来自Docker Hub的Docker图像,我可以通过点击它们的存储库API来检索图像的当前标记列表。例如,https://registry.hub.docker.com/v1/repositories/python/tags将给我一个标签列表,这些标签可以与docker pull python一起使用: 对于弹性搜索,我使用他们的官方存储库,可以使用类似于docker-pull-docker.Elastic.co/elasticsearch/elasticsearch:6.4.0 但是
https://registry.hub.docker.com/v1/repositories/python/tags
将给我一个标签列表,这些标签可以与docker pull python一起使用:
对于弹性搜索,我使用他们的官方存储库,可以使用类似于docker-pull-docker.Elastic.co/elasticsearch/elasticsearch:6.4.0
但是,我不知道如何从该存储库中提取标签列表。我试过了
https://docker.elastic.co/elasticsearch/elasticsearch/tags
https://docker.elastic.co/v1/repositories/elasticsearch
https://docker.elastic.co/v2/repositories/elasticsearch/elasticsearch/_manifests/tags
…和其他几个变体。docker命令行工具在后端请求中将存储库/图像名称转换为什么URL/API端点?您可以尝试与python相同的方法来获得可用的标记/版本列表 例如: 示例输出:
[{“层”:“,“名称”:“1”},{“层”:“,“名称”:“1-alpine”}]
因此,您将在shell脚本中提供一个provision/show标记列表,并要求他们选择。然后基于此,您将在自定义docker文件中执行docker pull并运行这些命令 您可以尝试与python相同的方法来获得可用的标签/版本列表 例如: 示例输出:
[{“层”:“,“名称”:“1”},{“层”:“,“名称”:“1-alpine”}]
因此,您将在shell脚本中提供一个provision/show标记列表,并要求他们选择。然后基于此,您将在自定义docker文件中执行docker pull并运行这些命令 事实证明,
docker.elastic.co
正在运行V2 docker注册表,因此需要V2 API命令和令牌身份验证。尝试最初获取标记会导致401,其中包含有关如何获取令牌的信息:
http https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list (566ms)
HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Length: 170
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:24:42 GMT
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://docker-auth.elastic.co/auth",service="token-service",scope="repository:elasticsearch/elasticsearch:pull"
X-Content-Type-Options: nosniff
{
"errors": [
{
"code": "UNAUTHORIZED",
"detail": [
{
"Action": "pull",
"Class": "",
"Name": "elasticsearch/elasticsearch",
"Type": "repository"
}
],
"message": "authentication required"
}
]
}
http -v https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list 'Authorization: Bearer some-long-token'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1765
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:26:18 GMT
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
{
"name": "elasticsearch/elasticsearch",
"tags": [
"5.0.0-731e78df",
"5.0.0-86a0b164",
"5.0.0-alpha5",
"5.0.0-beta1",
"5.0.0-ccd69424",
"5.0.0-rc1",
"5.0.0",
...
...
...
使用WWW Authenticate
中的信息为给定的服务
和范围
请求令牌:
http "https://docker-auth.elastic.co/auth?service=token-service&scope=repository:elasticsearch/elasticsearch:pull" (567ms)
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 790
Content-Type: application/json
Date: Thu, 09 May 2019 15:25:37 GMT
{
"token": "some-long-token"
}
最后,使用令牌发出请求:
http https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list (566ms)
HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Length: 170
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:24:42 GMT
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://docker-auth.elastic.co/auth",service="token-service",scope="repository:elasticsearch/elasticsearch:pull"
X-Content-Type-Options: nosniff
{
"errors": [
{
"code": "UNAUTHORIZED",
"detail": [
{
"Action": "pull",
"Class": "",
"Name": "elasticsearch/elasticsearch",
"Type": "repository"
}
],
"message": "authentication required"
}
]
}
http -v https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list 'Authorization: Bearer some-long-token'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1765
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:26:18 GMT
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
{
"name": "elasticsearch/elasticsearch",
"tags": [
"5.0.0-731e78df",
"5.0.0-86a0b164",
"5.0.0-alpha5",
"5.0.0-beta1",
"5.0.0-ccd69424",
"5.0.0-rc1",
"5.0.0",
...
...
...
原来,
docker.elastic.co
正在运行V2 docker注册表,因此需要V2 API命令和令牌身份验证。尝试最初获取标记会导致401,其中包含有关如何获取令牌的信息:
http https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list (566ms)
HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Length: 170
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:24:42 GMT
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://docker-auth.elastic.co/auth",service="token-service",scope="repository:elasticsearch/elasticsearch:pull"
X-Content-Type-Options: nosniff
{
"errors": [
{
"code": "UNAUTHORIZED",
"detail": [
{
"Action": "pull",
"Class": "",
"Name": "elasticsearch/elasticsearch",
"Type": "repository"
}
],
"message": "authentication required"
}
]
}
http -v https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list 'Authorization: Bearer some-long-token'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1765
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:26:18 GMT
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
{
"name": "elasticsearch/elasticsearch",
"tags": [
"5.0.0-731e78df",
"5.0.0-86a0b164",
"5.0.0-alpha5",
"5.0.0-beta1",
"5.0.0-ccd69424",
"5.0.0-rc1",
"5.0.0",
...
...
...
使用WWW Authenticate
中的信息为给定的服务
和范围
请求令牌:
http "https://docker-auth.elastic.co/auth?service=token-service&scope=repository:elasticsearch/elasticsearch:pull" (567ms)
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 790
Content-Type: application/json
Date: Thu, 09 May 2019 15:25:37 GMT
{
"token": "some-long-token"
}
最后,使用令牌发出请求:
http https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list (566ms)
HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Length: 170
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:24:42 GMT
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://docker-auth.elastic.co/auth",service="token-service",scope="repository:elasticsearch/elasticsearch:pull"
X-Content-Type-Options: nosniff
{
"errors": [
{
"code": "UNAUTHORIZED",
"detail": [
{
"Action": "pull",
"Class": "",
"Name": "elasticsearch/elasticsearch",
"Type": "repository"
}
],
"message": "authentication required"
}
]
}
http -v https://docker.elastic.co/v2/elasticsearch/elasticsearch/tags/list 'Authorization: Bearer some-long-token'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1765
Content-Type: application/json; charset=utf-8
Date: Thu, 09 May 2019 15:26:18 GMT
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
{
"name": "elasticsearch/elasticsearch",
"tags": [
"5.0.0-731e78df",
"5.0.0-86a0b164",
"5.0.0-alpha5",
"5.0.0-beta1",
"5.0.0-ccd69424",
"5.0.0-rc1",
"5.0.0",
...
...
...
这不是同一个存储库。当你从docker.elastic.co上拉一把时,它使用的是docker.elastic.co,而不是hub.docker.com。我找到了答案。看到我上面的答案,很高兴听到这个建议,因为只有我提到的从docker hub中提取图像列表。因为他们一直在镜像那些与弹性相关的图像(不要认为所有弹性docker图像都是:)。Ref:那不是同一个存储库。当你从docker.elastic.co上拉一把时,它使用的是docker.elastic.co,而不是hub.docker.com。我找到了答案。看到我上面的答案,很高兴听到这个建议,因为只有我提到的从docker hub中提取图像列表。因为他们一直在镜像那些与弹性相关的图像(不要认为所有弹性docker图像都是:)。裁判: