liveBook · Manning

Cloud Run

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

Google Cloud Run is a managed Google Cloud platform for running containerized applications without managing servers.

Cloud Run runs containerized applications on Google Cloud without requiring you to provision virtual machines, install Docker, or manage networks and storage. It provides a simpler managed container platform while retaining access to broader cloud functionality. section 14.0

A practical Cloud Run workflow includes:

  • Create or select a Google Cloud project, link billing, and enable the required services. section 14.4
  • Create an Artifact Registry repository, authenticate Docker, retag the container image, and push it to the regional registry path. section 14.4
  • Deploy a container as a Cloud Run job, execute it, and read its logs. section 14.4
  • Deploy a web container as a Cloud Run service, configure its port and unauthenticated access, then test its service URL. 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

Initialize the Google Cloud CLI, create a project, connect billing, and enable Artifact Registry before publishing images. 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"

Create the regional Docker repository, configure Docker authentication, and push a retagged application image. section 14.4

Run a job and deploy a web service

Deploy the hello-cloud image as a Cloud Run job, execute it, and read its logs. Then publish pi-web to Artifact Registry and deploy it with port 80 and unauthenticated access; inspect the service details and open its URL. section 14.4

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

How deep it goes
Explains project setup, registry publishing, job execution, service deployment, and verification, but does not develop platform internals.
Examples
Uses hello-cloud for a batch job and pi-web for a public web service, with commands for publishing, execution, logs, and URL testing.
What it assumes
Assumes a Google Cloud account and gcloud installation while building project, billing, registry, authentication, and deployment knowledge incrementally.
What you can do after
Operate Cloud Run through gcloud by publishing images to Artifact Registry and deploying jobs or web services.
How it connects
Connects containers with Google Cloud projects, billing accounts, Artifact Registry, Docker CLI, and the gcloud CLI.

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.