Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker API v2 - how to tag and push an image

Tags:

docker

I want to promote image from test to prod environment. How do I use "curl POST" to tag and push an image thru docker registry API v2? (Docker API 1.22) The equivalent command are:

docker tag my_testrepo:6000/new_test_image:test_tag myprod_repo:5000/new_prod_image:tag
docker push myprod_repo:5000/new_prod_image:tag

How do I use curl command to tag an image into a repo:

POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1

Could not find any instructions. Tried many times, all failed.

like image 966
ezlee Avatar asked Jan 16 '17 02:01

ezlee


1 Answers

While researching this issue I stumbled upon this question. The solution I found resolved around this blog post. Credit to wheleph for the solution.

Essentially there is no method to tag an existing image, you can simply download the manifest of the existing tag, and re-upload the manifest as a new tag:

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

Then upload that manifest file back up.

curl -XPUT '/v2/mybusybox/manifests/new_tag' -H 'content-type: application/vnd.docker.distribution.manifest.v2+json' -d '@manifest.json'
like image 122
jrbeverly Avatar answered Oct 29 '22 19:10

jrbeverly