Anusha Madhusudhanan
Anusha Madhusudhanan

Reputation: 55

Skopeo tool for docker images - Retagging

I am downloading a docker image using Skopeo tool on a linux machine - Works successfully

skopeo copy --src-creds uname:pwd docker://url/image:tag dir:/home/image

I am trying to change the tag of this image. Currently the image tag is "latest" which needs to be changed as "new"

Is there any way using skopeo tool we can re-tag this image then upload to registry with a new tag.

Please Note: Docker is not allowed to be installed on linux machine as it needs root user which is unauthorized for our project.

I am trying the below sequence of activities

  1. Download an image from repository with tag "latest"- working
  2. Change the tag of the image to "new" and upload back to repository - working
  3. Download the image with new tag "new" - Fails with error.

PFB the commands in sequential order

skopeo copy --src-creds name:pwd docker://url/alpine:latest dir:/home/alpine

skopeo copy --dest-creds uname:pwd dir:/home/alpine docker://url/alpine:new 

skopeo copy --src-creds uname:pwd docker://url/alpine:new dir:./alpinenew
**FATA[0004] Error initializing source docker://url/alpine:new: Error reading manifest new in url/alpine: manifest unknown: manifest unknown**

How to fix this error.

Upvotes: 0

Views: 3580

Answers (1)

larsks
larsks

Reputation: 312370

You don't need to "retag" the image. You set the tag when you upload the image to a remote repository. For example, to upload the image as myusername/myimagename:sometag, I could run:

skopeo copy dir:/home/image docker://myusername/myimagename:sometag

To illustrate this, I can download the alpine image like this:

skopeo copy docker://alpine dir:./alpine

And then upload this into my own namespace with a different name and tag like this:

skopeo copy dir:alpine docker://larsks/alpinetest:foo

That seems to work just fine.

I can then download the new image to verify that it worked:

$ skopeo copy docker://larsks/alpinetest:foo dir:./alpinetest
Getting image source signatures
Copying blob e6b0cf9c0882 done
Copying config cc0abc535e done
Writing manifest to image destination
Storing signatures

This works just fine using the same image name in both locations:

skopeo copy docker://larsks/alpinetest:foo dir:./alpinetest
skopeo copy dir:./alpinetest docker://larsks/alpinetest:bar

This adds a new tag to the image.

Upvotes: 0

Related Questions