如何获取将图像的最新图像版本(标签)推向Google容器注册表



我需要使用API推到GCR的20-30个最新图像版本的列表。

我知道我们可以使用https://cloud.google.com/sdk/gcloud/reference/container/images/list。但是我想要使用API。我已经使用了https://github.com/google/nodejs-container-image-builder#registry-client-api中提到的注册表 - client API的client.tags()。它提供了所有图像标签,但是我需要推出的最新图像版本的列表,从最新到最低版本开始。是否有任何模块或API可以完成此操作?

我不熟悉特定的SDK,但熟悉GCR和注册表API。

您的问题是client.tags()不返回时间戳吗?

gcloud的一个有用的技巧是,您可以将--log-http附加到任何命令中,以查看命令正在做的基础API调用:

这是使用我的公共注册表之一的示例:

gcloud container images list-tags gcr.io/image-transparency/server 
--project=image-transparency 
--log-http

结果:

...
==== request start ====
uri: https://gcr.io/v2/image-transparency/server/tags/list
method: GET
== headers start ==
Authorization: --- Token Redacted ---
...
== headers end ==
==== request end ====
---- response start ----
...
-- body start --
{"child":[],"manifest":{"sha256:0e0a9839dcd8a6ab45fd62c0b70eb13b11af7258239be4114afa516bb7508172":{"imageSizeBytes":"8723924","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["7692bab2a81a9f1028387e07aa8b81c6a03eb92e"],"timeCreatedMs":"1563309309184","timeUploadedMs":"1563309938603"},"sha256:1d84df6f23968ea23ae1fa6ba47981931b0e8076598fffacfa275abdf94148dd":{"imageSizeBytes":"8227740","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["551904f38ccf2a1bfd45aac16a2c1ce4037975f2"],"timeCreatedMs":"1563400894425","timeUploadedMs":"1563400943736"},"sha256:4f762b4c9979fdbad84e07368ef1efef95c8f7e9cccb2bed96bfd95df42efac8":{"imageSizeBytes":"8611114","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["c9afbd4b428ad6dc8af291234bbe94f605cdbcd4"],"timeCreatedMs":"1562791496351","timeUploadedMs":"1562791551281"},"sha256:51fa2c1f378266ef5ee6f1f5137f16ff0bbde4c14585dae444dfc7923c1a4ed9":{"imageSizeBytes":"8611115","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["6b79683a1a3a3b83f314b4585e04b9e14e28081d"],"timeCreatedMs":"1562790199324","timeUploadedMs":"1562790247774"},"sha256:6e159709d9fe9e1bcfaccb1b7ceaad72b20da8ee8cfc2444cf617417c2e006e9":{"imageSizeBytes":"8722781","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":[],"timeCreatedMs":"1563305927430","timeUploadedMs":"1563305976876"},"sha256:8a2c0acf0fc06a45a5b04fc3411732bfa50f2115e60793d2d7f64ae9107253aa":{"imageSizeBytes":"8229487","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["034ca01c8d599dd8ef704986fee631ca3462a912"],"timeCreatedMs":"1563394435023","timeUploadedMs":"1563394483433"},"sha256:8b777848e959fc64c30a6e3f534c9a92f47418bd1e708364971b75c24d2a87ad":{"imageSizeBytes":"8611968","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["bcdc26eb174dca7cb44b2e5d8e958df7c5a04ba6"],"timeCreatedMs":"1562791134937","timeUploadedMs":"1562791306243"},"sha256:c5e1288b68bc941c9544123210e62e2ab1f66d44768116be8757b45e4cbf1b76":{"imageSizeBytes":"8611114","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["184fb77a23aa3a4a3a7d5f4ebcc9f398b012952e"],"timeCreatedMs":"1562795024694","timeUploadedMs":"1562795072187"},"sha256:d125cdfbf8b0a4db6b8043d51362bd20ce079b376bc28062a8a498d2edd79e82":{"imageSizeBytes":"8722781","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["d2be230c73035576ea3d802cdb49afbc7838f383"],"timeCreatedMs":"1563383711328","timeUploadedMs":"1563383757204"},"sha256:fd5d26d3a69772fbf590df11138d9599d9d71e269e068f8af136097fa2dd9095":{"imageSizeBytes":"8611115","layerId":"","mediaType":"application/vnd.docker.distribution.manifest.v2+json","tag":["8336372726d1489bdf6e48ae675a09d795ff8223"],"timeCreatedMs":"1562794705526","timeUploadedMs":"1562794752708"}},"name":"image-transparency/server","tags":["034ca01c8d599dd8ef704986fee631ca3462a912","184fb77a23aa3a4a3a7d5f4ebcc9f398b012952e","551904f38ccf2a1bfd45aac16a2c1ce4037975f2","6b79683a1a3a3b83f314b4585e04b9e14e28081d","7692bab2a81a9f1028387e07aa8b81c6a03eb92e","8336372726d1489bdf6e48ae675a09d795ff8223","bcdc26eb174dca7cb44b2e5d8e958df7c5a04ba6","c9afbd4b428ad6dc8af291234bbe94f605cdbcd4","d2be230c73035576ea3d802cdb49afbc7838f383"]}
-- body end --
total round trip time (request+response): 0.191 secs
---- response end ----
----------------------
DIGEST        TAGS                                      TIMESTAMP
1d84df6f2396  551904f38ccf2a1bfd45aac16a2c1ce4037975f2  2019-07-17T15:01:34
8a2c0acf0fc0  034ca01c8d599dd8ef704986fee631ca3462a912  2019-07-17T13:13:55
d125cdfbf8b0  d2be230c73035576ea3d802cdb49afbc7838f383  2019-07-17T10:15:11
0e0a9839dcd8  7692bab2a81a9f1028387e07aa8b81c6a03eb92e  2019-07-16T13:35:09
6e159709d9fe                                            2019-07-16T12:38:47
c5e1288b68bc  184fb77a23aa3a4a3a7d5f4ebcc9f398b012952e  2019-07-10T14:43:45
fd5d26d3a697  8336372726d1489bdf6e48ae675a09d795ff8223  2019-07-10T14:38:26
4f762b4c9979  c9afbd4b428ad6dc8af291234bbe94f605cdbcd4  2019-07-10T13:44:56
8b777848e959  bcdc26eb174dca7cb44b2e5d8e958df7c5a04ba6  2019-07-10T13:38:55
51fa2c1f3782  6b79683a1a3a3b83f314b4585e04b9e14e28081d  2019-07-10T13:23:19

GCR使用Docker的注册表API V2(并且,根据我的经验,正确实现了API |完全实现(。我建议您考虑如果SDK不足,请考虑使用它。

,但请同时提交针对SDK的功能请求。

我在此处写了关于我在此处使用注册表API的经历,并包括示例 curl'ing gcr:

https://medium.com/google-cloud/adventures-w-docker-manifests-78f25555662ff

相关内容

  • 没有找到相关文章

最新更新