简体   繁体   English

用人工制品中的最新标签覆盖 docker 图像

[英]Overwrite docker image with latest tag in artifactory

I am currently Pushing same image twice one with tag number and another with latest tag to artifactory.我目前正在将同一图像两次推送到 artifactory,一个带有标签号,另一个带有最新标签。

For the next release I would like to overwrite the image with latest tag with the new image that contains latest tag.对于下一个版本,我想用包含最新标签的新图像覆盖带有最新标签的图像。 Below is the way I am trying from Azure devops build以下是我从 Azure devops build 尝试的方式

Docker Build Command:
     $(docker_registry)/$(Build.Repository.Name):$(BuildNbr)
Docker Push Command
      $(docker_registry)/$(Build.Repository.Name):$(BuildNbr)

Same above with latest tag, then与上面的最新标签相同,然后

docker pull $(docker_registry)/imageName:latest

docker rmi --force $(docker_registry)/imageName:latest   //removing latest image from artifactory NOT WORKING

docker pull $(docker_registry)/imageName:$(BuildNbr)

docker tag $(docker_registry)/imageName:$(BuildNbr) $(docker_registry)/imageName:latest

docker push $(docker_registry)/imageName:latest

Somehow the above flow is not working and the latest image is not getting overwritten.不知何故,上面的流程不起作用,最新的图像没有被覆盖。

Am I doing any mistake?我做错了吗? I believe rmi command will not delete the image from artifactory.我相信 rmi 命令不会从 artifactory 中删除图像。

You can achieve it through the include/exclude pattern for your permissions.您可以通过权限的包含/排除模式来实现它。 You can create a new Permission Target that gives overwrite/delete permissions to tags with "latest" in it:您可以创建一个新的权限目标,为其中包含“最新”的标签提供覆盖/删除权限:

  1. Remove the include pattern **删除包含模式**
  2. Add the include pattern **/latest/*添加包含模式**/latest/*
  3. Add only the required docker repositories (for example "docker local")仅添加所需的 docker 存储库(例如“docker local”)
  4. Add anyone to this permission target that needs to be able to overwrite/delete.将需要能够覆盖/删除的任何人添加到此权限目标。

在此处输入图像描述

Then, for all other permission targets, which defines the remainder of the tags (1.1, 1.2, etc), do not provide overwrite/delete permissions.然后,对于定义其余标记(1.1、1.2 等)的所有其他权限目标,不提供覆盖/删除权限。 With this, you will be able to overwrite the latest and not other tags.有了这个,您将能够覆盖最新的而不是其他标签。

You can read about include/exclude patterns as they relate to permission targets here .您可以在此处阅读与权限目标相关的包含/排除模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM