How to copy artifacts between projects in Google Artifact Registry

3.7k views Asked by At

Previously using Container Registry one could copy a container between projects using this method

However I am unable to get this working using Artifact Registry. If I try

gcloud artifacts docker tags add \
        us-east4-docker.pkg.dev/source-proj/my-repo/my-image:latest \
        us-east4-docker.pkg.dev/dest-proj/my-repo/my-image:latest

It gives the error

ERROR: (gcloud.artifacts.docker.tags.add) Image us-east4-docker.pkg.dev/source-proj/my-repo/my-image
does not match image us-east4-docker.pkg.dev/dest-proj/my-repo/my-image

I have searched and can not find any examples or documentation on how to do this.

2

There are 2 answers

2
Gourav B On

You can use the gcrane tool to copy images in Artifact Registry.

For example, the following command copies image my-image:latest from the repository my-repo in the project source-proj to the repository my-repo in another project called dest-proj.

gcrane cp \
    us-east4-docker.pkg.dev/source-proj/my-repo/my-image:latest \
    us-east4-docker.pkg.dev/dest-proj/my-repo/my-image:latest

Here is the link to the Google Cloud official documentation.

2
James On

This can be done using gcrane cp us-east4-docker.pkg.dev/source-proj/my-repo/my-image:latest us-east4-docker.pkg.dev/dest-proj/my-repo/my-image:latest