Reputation: 22129
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 ?
Upvotes: 5
Views: 6117
Reputation: 312370
You can perform the rename in a single step using skopeo, like this:
skopeo copy \
docker://xx.xx.xx.xx:5000/library/ruby:2.2.1 \
docker://xx.xx.xx.xx:5000/library/new_name:latest
If the source and destination image are in the same namespace (which these are), this should not require actually copying any data because the layers already exist in the target. The same is true of your pull/retag/push procedure, but this is a single step so perhaps more convenient.
Upvotes: 3
Reputation: 691
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!
Upvotes: 3