如何在docker注册表v2中标记图像 [英] how to tag image in docker registry v2

查看:170
本文介绍了如何在docker注册表v2中标记图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的CI-CD中的逻辑将标签(通过REST)分段映像标记为最新(如果测试成功)。这个工作在注册表v1。



现在移动到v2 api,我在文档中找不到如何添加标签到注册表中的现有图像我' m在一步可以带来清单的一些分期图像,但不知道如何添加标签和http发布。
尝试发送以下输入


  1. tag:staging,latest,


  2. tag:[staging,latest],
    和更多



    {
    schemaVersion:1,
    name:configservice,
    tag:staging,
    architecture:amd64,
    fsLayers:[....



解决方案

Docker注册表支持清单模式版本2,您只需在新标签下载现有图像的清单即可。



例如,假设您要标记最新版本的 busybox 图像。步骤如下:



下载现有清单

  curl'< registry_url> / v2 / mybusybox / manifest / latest'\ 
-H'accept:application / vnd.docker.distribution.manifest.v2 + json'\
> manifest.json

清单可能看起来像这样(注意schemaVersion是2):

  {
schemaVersion:2,
mediaType:application /
config:{
mediaType:application / octet-stream,
size:1459,
digest:sha256:2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749
},
layers:[
{
mediaType:application / vnd.docker.image.rootfs。 diff.tar.gzip,
size:667590,
digest:sha256:8ddc19f16526912237dd8af81971d5e4dd0587907234be2b83e249518d5b673f
}
]
}

在新标签下上传清单:

  curl -XPUT'< registry_url> / v2 / mybusybox / manifest / new_tag'\ 
-H'content-type:application / vnd.docker.distributio n.manifest.v2 + json'\
-d'@ manifest.json'

详细的分步指南是在这个 post


We have logic in our CI-CD that tags (via REST) staging image to latest (if tests are successful). This worked on registry v1.

now moved to v2 api, and I can't find in documentation how to "add" tags to existing image in registry..I'm in a step that can bring the "manifest" of some staging image, but not sure how to add tag and http-post it. tried to send the below input

  1. "tag": "staging","latest",

  2. "tag": ["staging","latest"], and more

    { "schemaVersion": 1, "name": "configservice", "tag": "staging", "architecture": "amd64", "fsLayers": [....

解决方案

If you have Docker Registry that supports manifest schema version 2, you can just upload the manifest of an existing image under a new tag.

For example let's assume that you want to tag latest version of busybox image. The steps would be:

Download the existing manifest:

curl '<registry_url>/v2/mybusybox/manifests/latest' \
-H 'accept: application/vnd.docker.distribution.manifest.v2+json' \
> manifest.json

Here's what the manifest might look like (notice that schemaVersion is 2):

{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
   "config": {
      "mediaType": "application/octet-stream",
      "size": 1459,
      "digest": "sha256:2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749"
   },
   "layers": [
      {
         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
         "size": 667590,
         "digest": "sha256:8ddc19f16526912237dd8af81971d5e4dd0587907234be2b83e249518d5b673f"
      }
   ]
}

Upload the manifest under a new tag:

curl -XPUT '<registry_url>/v2/mybusybox/manifests/new_tag' \
-H 'content-type: application/vnd.docker.distribution.manifest.v2+json' \
-d '@manifest.json'

Detailed step-by-step guide is give in this post.

这篇关于如何在docker注册表v2中标记图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆