Artifactory 更改仓库内 Docker 镜像标签

huangapple go评论64阅读模式
英文:

Artifactory change docker image tag inside one repo

问题

I want to change the tags from my docker images in Artifactory using the REST API. The only possible way to make this work I could find out is to promote the image to another repository and promote it back while changing the tag.

I really don't want to create another repository only to move my image there and afterwards back.

When I tried to promote the image to the source repository I get this error message:

{
  "errors" : [ {
    "status" : 400,
    "message" : "Skipping promote since destination and source are the same"
  } ]
}
英文:

I want to change the tags from my docker images in Artifactory using the REST API. The only possible way to make this work I could find out is to promote the image to an other repository and promote it back while changing the tag.

I really don't want to create an other repository only to move my image there and afterwards back.

When I tried to promote the image to the source repository I get this error message:

{\n  "errors" : [ {\n    "status" : 400,\n    "message" : "Skipping promote since destination and source are the same"\n  } ]\n}'

答案1

得分: 1

以下是翻译好的部分:

可以按照你在问题中提到的方式推广 Docker 镜像。在这种情况下,镜像将被移动/推广,与之相关的属性(例如,当单击 manifest.json 时可以在 UI 中找到)将相应更改。

另一个选项,类似于你找到的选项,是使用移动 REST-API 调用(而不是复制),以更改镜像路径(以及相应的标签,因为它是根据路径来确定的),然后不需要执行其他操作,例如删除:

$ curl -uadmin -XPOST "http://<Artifactory-URL>/artifactory/api/move/<Docker-Repo>/<Image-Name>/<Tag-Name>?to=/<Docker-Repo>/<Image-Name>/<New-Tag-Name>"

请注意,在这种情况下(无论是移动还是复制),属性(例如标签名称的属性)不会在执行该操作后更改,但不会影响功能,Docker 镜像可以根据其移动到的新路径使用新标签进行拉取。话虽如此,如果你希望保持新路径和属性的一致性,也可以在更改后手动更改属性。

此外,类似于移动 REST-API 调用,还可以直接从 Artifactory UI 中通过右键单击图像执行移动操作。

当然,还有一个选项是拉取 -> 重新标记 -> 推送并删除旧镜像。

英文:

It is possible to promote a Docker image as you mentioned in the question.
In this case the image will be moved/promoted and the properties for that image (e.g can be found in the UI when clicking on the manifest.json) will be changed with it accordingly.

Another option, similar to the one you found is with the Move REST-API call (instead of Copy) to change the image path (and with it the tag as it’s according to the path) and then it will not be required to have an additional action and also delete, for example:

$ curl -uadmin -XPOST &quot;http://&lt;Artifactory-URL&gt;/artifactory/api/move/&lt;Docker-Repo&gt;/&lt;Image-Name&gt;/&lt;Tag-Name&gt;?to=/&lt;Docker-Repo&gt;/&lt;Image-Name&gt;/&lt;New-Tag-Name&gt;”

Note that in this case (both for move/copy) the properties (e.g the property for the tag name) will not be changed following that action), however, it will not affect the functionality and the Docker image can be pulled with the new tag according to the new path it was moved to.
That being said the properties can also be changed manually after the change if you’d like to keep the new path and properties aligned.

In addition, similar to the Move REST-API call, the move operation can also be done directly from Artifactory UI by right clicking on the image.

Of course there's also the option to Pull -> Re-Tag -> Push and delete the old image.

答案2

得分: 0

I have found a workaround. They way you do it is to use Copy Item and delete it afterwards.

POST /api/copy/{srcRepoKey}/{srcFilePath}?to=/{targetRepoKey}/{targetFilePath}[&amp;dry=1][&amp;suppressLayouts=0/1(default)][&amp;failFast=0/1]

Link to the docu

I don't understand why they don't list this information next to the documentation of promoting an image. In general the new Artifactory documentation is really bad. I don't like it and hope they revert it.

英文:

I have found a workaround. They way you do it is to use Copy Item and delete it afterwards.

 POST /api/copy/{srcRepoKey}/{srcFilePath}?to=/{targetRepoKey}/{targetFilePath}[&amp;dry=1][&amp;suppressLayouts=0/1(default)][&amp;failFast=0/1]

Link to the docu

I don't understand why they don't list this information next to the documentation of promoting an image. In general the new Artifactory documentation is really bad. I don't like it and hope they revert it.

huangapple
  • 本文由 发表于 2023年4月19日 22:02:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055455.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定