I have an images in my remote docker registry:
xx.xx.xx.xx:5000/library/ruby:2.2.1
Is there a quick way or existing command to rename it?
I know I can implement this by executing docker pull
it to local and rename it by docker tag
and then docker push
again.
docker pull xx.xx.xx.xx:5000/library/ruby:2.2.1
docker tag xx.xx.xx.xx:5000/library/ruby:2.2.1 xx.xx.xx:5000/library/new_name:latest
docker push xx.xx.xx.xx:5000/library/new_name:latest
But since pulling and push images cost time, I wonder if there is an quick way to rename it ?
There are two different methods:
a) If you just want to change the TAG:
the answer https://stackoverflow.com/a/38362476/8430173 works only for changing TAG
b) If you want to change the repository name too:
by many thanks to this, I changed the repoName too!
(by help of his Github project):
1- get manifests (in v2 schema)
2- post every layer.digest in the new repo
3- post config.layer
4- put whole manifest to new repo
1- GET manifest from reg:5000/v2/{oldRepo}/manifests/{oldtag}
withaccept
header:application/vnd.docker.distribution.manifest.v2+json
2- for every layer : POST reg:5000/v2/{newRepo}/blobs/uploads/?mount={layer.digest}&from={oldRepoNameWithaoutTag}
3- POST reg:5000/v2/{newRepo}/blobs/uploads/?mount={config.digest}&from={oldRepoNameWithaoutTag}
4- PUT reg:5000/v2/{newRepo}/manifests/{newTag}
with content-type
header:application/vnd.docker.distribution.manifest.v2+json
and body
from step 1 response
5- enjoy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With