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
