liveBook · Manning

Artifact Registry

As explained in Learn Docker in a Month of Lunches, Second Edition

Artifact Registry is Google Cloud's managed service for storing and distributing software artifacts such as container images and packages.

Artifact Registry provides a Google Cloud repository for container images used by Cloud Run. Before deploying, create a repository, authenticate Docker, retag the image with Google Cloud’s reference format, and push it. section 14.4

Use this workflow to prepare an image for Cloud Run:

  • Create or select a Google Cloud project, connect billing, and enable the Artifact Registry service. section 14.4
  • Create a Docker repository in a chosen region, then inspect it to obtain the registry domain. section 14.4
  • Configure Docker authentication, pull the source image, retag it, and push the new reference. section 14.4
  • Deploy the pushed image to a Cloud Run job or service and verify it by executing the job, reading logs, or opening the service URL. section 14.4

Image reference

An image pulled as ghcr.io/diamol2e/ch14-hello-cloud can be retagged as us-east1-docker.pkg.dev/diamol2ees/ch14/hello-cloud. The reference combines the regional registry domain, project, repository, and image name. section 14.4

# create the registry in your project:
gcloud artifacts repositories create ch14 `
 --repository-format=docker --project=$PROJECT --location=$REGION
# print the information - this includes the registry domain:
gcloud artifacts repositories describe ch14 `
 --project=$PROJECT --location=$REGION
# store the domain in a variable - PowerShell:
$REGISTRY="${REGION}-docker.pkg.dev"
# OR Linux shell:
REGISTRY="${REGION}-docker.pkg.dev"
# authenticate the registry with the Docker CLI:
gcloud auth configure-docker --quiet $REGISTRY

# pull the source image:
docker pull ghcr.io/diamol2e/ch14-hello-cloud
# tag it with your Artifact Registry reference:
docker tag ghcr.io/diamol2e/ch14-hello-cloud `
 "$REGISTRY/$PROJECT/ch14/hello-cloud"
# and push:
docker push "$REGISTRY/$PROJECT/ch14/hello-cloud"

Follow the runnable commands for creating a Docker repository, discovering its domain, authenticating Docker, and pushing an image. section 14.4

# initialize your CLI (if you haven't already):
gcloud init
# store variables - you will need a unique project name,
# and any region will do; with PowerShell:
$REGION='us-east1'
$PROJECT='<your-project-name>'
# OR Linux shell:
REGION='us-east1'
PROJECT='<your-project-name>'
# create the project:
gcloud projects create $PROJECT
# list your billing accounts:
gcloud billing accounts list
# link your new project to the billing account:
gcloud billing projects link $PROJECT `
 --billing-account=<your-billing-account-id>
# and now enable the Artifact Registry service:
gcloud services enable artifactregistry.googleapis.com `
 --project=$PROJECT

Use the setup commands to initialize gcloud, create a project, link billing, and enable Artifact Registry. section 14.4

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Walks through project setup, repository creation, Docker authentication, image pushing, and Cloud Run verification.
Examples
Uses hello-cloud and pi-web images, Docker tags, repository commands, Cloud Run jobs, and Cloud Run services.
What it assumes
Assumes a Google Cloud account, billing access, and gcloud and Docker CLIs while guiding project setup.
What you can do after
Operate Artifact Registry via gcloud and Docker, then deploy its images to Cloud Run.
How it connects
Connects Google Cloud projects, Docker, container images, Cloud Run, and Google Cloud Build.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.