Google Cloud Container Registry

Storing container images in GCP.

The GCP container registry is a container registry flavor that comes built-in with ZenML and uses the Google Artifact Registry or the Google Container Registry to store container images.

When to use it

You should use the GCP container registry if:

  • one or more components of your stack need to pull or push container images.

  • you have access to GCP. If you're not using GCP, take a look at the other container registry flavors.

How to deploy it

The GCP container registry (and GCP integration in general) currently only works for Python versions <3.11. The ZenML team is aware of this dependency clash/issue and is working on a fix. For now, please use Python <3.11 together with the GCP integration.

When using the Google Container Registry, all you need to do is enable it here.

Infrastructure Deployment

A GCP Container Registry can be deployed directly from the ZenML CLI:

zenml container-registry deploy gcp_container_registry --flavor=gcp --provider=gcp ...

You can pass other configurations specific to the stack components as key-value arguments. If you don't provide a name, a random one is generated for you. For more information about how to work use the CLI for this, please refer to the dedicated documentation section.

How to find the registry URI

When using the Google Container Registry, the GCP container registry URI should have one of the following formats:

gcr.io/<PROJECT_ID>
# or
us.gcr.io/<PROJECT_ID>
# or
eu.gcr.io/<PROJECT_ID>
# or
asia.gcr.io/<PROJECT_ID>

# Examples:
gcr.io/zenml
us.gcr.io/my-project
asia.gcr.io/another-project

To figure out the URI for your registry:

  • Go to the GCP console.

  • Click on the dropdown menu in the top left to get a list of available projects with their names and IDs.

  • Use the ID of the project you want to use fill in the template gcr.io/<PROJECT_ID> and get your URI (You can also use the other prefixes <us/eu/asia>.gcr.io as explained above if you want your images stored in a different region).

Infrastructure Deployment

A GCP Container Registry can be deployed directly from the ZenML CLI:

zenml container-registry deploy gcp_container_registry --flavor=gcp --provider=gcp ...

You can pass other configurations specific to the stack components as key-value arguments. If you don't provide a name, a random one is generated for you. For more information about how to work use the CLI for this, please refer to the dedicated documentation section.

How to use it

To use the GCP container registry, we need:

  • Docker installed and running.

  • The registry URI. Check out the previous section on the URI format and how to get the URI for your registry.

We can then register the container registry and use it in our active stack:

zenml container-registry register <NAME> \
    --flavor=gcp \
    --uri=<REGISTRY_URI>

# Add the container registry to the active stack
zenml stack update -c <NAME>

You also need to set up authentication required to log in to the container registry.

Authentication Methods

Integrating and using a GCP Container Registry in your pipelines is not possible without employing some form of authentication. If you're looking for a quick way to get started locally, you can use the Local Authentication method. However, the recommended way to authenticate to the GCP cloud platform is through a GCP Service Connector. This is particularly useful if you are configuring ZenML stacks that combine the GCP Container Registry with other remote stack components also running in GCP.

This method uses the Docker client authentication available in the environment where the ZenML code is running. On your local machine, this is the quickest way to configure a GCP Container Registry. You don't need to supply credentials explicitly when you register the GCP Container Registry, as it leverages the local credentials and configuration that the GCP CLI and Docker client store on your local machine. However, you will need to install and set up the GCP CLI on your machine as a prerequisite, as covered in the GCP CLI documentation, before you register the GCP Container Registry.

With the GCP CLI installed and set up with credentials, we'll need to configure Docker, so it can pull and push images:

  • for a Google Container Registry:

    gcloud auth configure-docker
  • for a Google Artifact Registry:

    gcloud auth configure-docker <REGION>-docker.pkg.dev

Stacks using the GCP Container Registry set up with local authentication are not portable across environments. To make ZenML pipelines fully portable, it is recommended to use a GCP Service Connector to link your GCP Container Registry to the remote GCR registry.

For more information and a full list of configurable attributes of the GCP container registry, check out the API Docs .

Last updated