How to migrate docker images from private third party registry to Google artifact registry?

Viewed 159

I am looking to copy docker images from a third-party registry to google cloud's artifact registry because google does not support third-party private registries. here Docs

I worked around to pull the image from artifactory(third-party) and then push it to google cloud's artifact registry.

Is there any better way to do it?

1 Answers

The google artifact registry docs have a page on migrating artifacts from a third-party registry.

In it, they recommend using gcrane, an extension of the crane command-line utility developed by google for use managing containers, with extensions specific to gcr.io.

From the artifact registry docs:

The gcrane tool helps you with the copying process.

Create a text file images.txt in Cloud Shell with the names of the images you identified. For example:

ubuntu:18.04
debian:buster
hello-world:latest
redis:buster
jupyter/tensorflow-notebook

Download gcrane.

github.com/google/go-containerregistry/cmd/gcrane

Create a script named copy_images.sh to copy your list of files.

#!/bin/bash

images=$(cat images.txt)

if [ -z "${AR_PROJECT}" ] then
    echo ERROR: AR_PROJECT must be set before running this
    exit 1
fi

for img in ${images} do
    gcrane cp ${img} LOCATION-docker.pkg.dev/${AR_PROJECT}/${img}
done

Replace LOCATION with the region or multi-region of your repository.

Make the script executable:

chmod +x copy_images.sh

Run the script to copy the files:

AR_PROJECT=${PROJECT}
./copy_images.sh

The docs provide additional guidance on identifying images you need in your workflow, verifying permissions and updating manifests, costs, and more.

Related