Migrating Docker Images from Google Container Registry (gcr) to Artifacts Registry

Gabriel Xará
2 min readApr 11, 2024

Google Artifacts Registry is a universal package manager designed for both artifacts and dependencies. It introduces numerous improvements to the storage of Docker images, positioning it as the “next generation” successor to Google Container Registry (GCR).

Google has announced that GCR will be phased out by March 2025. If you are currently utilizing GCR for your Docker applications, this guide aims to assist you in the migration process.

The transition is intended to be straightforward, thanks in part to Google’s clear official documentation. Consequently, this guide will adopt a more direct, step-by-step approach. Should you require additional information, do not hesitate to consult the official documentation.

In this tutorial, we’ll use the following examples as region, project, and repository names:

REGION = us-central1
PROJECT_NAME = my_awesome_project
REPOSITORY_NAME = hello_world_repository

To successfully migrate, you’ll need to undertake the steps outlined below:

1) Identify which of your projects are utilizing Google Container Registry. If your projects are part of an organization, you can conveniently check all projects simultaneously by employing the --organization flag.

gcloud container images list-gcr-usage - organization=your_org_name

If you prefer (or if your project does not belong to an organization) you can verify the use of Google Container Registry in each of your projects individually by executing the following command:

gcloud container images list-gcr-usage - project=my_awesome_project

2) Enable the artifacts repository API for your project

gcloud services enable artifactregistry.googleapis.com

3) Create an artifacts repository for storing your docker images

gcloud artifacts repositories create hello_world_repository \
- repository-format=docker \
- location=us-central1 \
- description="describe your awesome application"

4) Authenticate Docker with your new repository.
Reference: Official documentation

I chose to use the gcloud CLI credential helper, considering it the most straightforward option for this task.

gcloud auth configure-docker us-central1-docker.pkg.dev

After completing the steps mentioned above, you should be able to push Docker images to your new repository! You can test this by running the following command in the directory where your Dockerfile is located:

docker build - tag us-central1-docker.pkg.dev/my_awesome_project/hello_world_repository/first-deploy:first-deploy .
docker push us-central1-docker.pkg.dev/my_awesome_project/hello_world_repository/first-deploy:first-deploy
echo "Image submitted to destination repository :)"
Container image appearing on Google Cloud Artifact Registry

--

--

Gabriel Xará

Software Engineer and Entrepreneur. Passionate about education and technology. Trying to revolutionize learning methodologies through cmaps.io