liveBook · Manning

GCP project

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

A Google Cloud project is an administrative resource that groups cloud services, resources, permissions, and billing associations.

A Google Cloud project groups services for an application. Before using Cloud Run, create the project, link it to a billing account, and explicitly enable the services it needs. section 14.4

Prepare a project for container workloads:

  • Create a uniquely named project with gcloud projects create. section 14.4
  • Link the project to a billing account before using paid cloud services. section 14.4
  • Enable required services explicitly, such as Artifact Registry and Cloud Run. section 14.4
  • Create an Artifact Registry repository inside the project and use the project name in the image reference. section 14.4

A project for Cloud Run

A project named diamol2ees can contain the ch14 Artifact Registry repository and Cloud Run workloads. An image can be addressed as us-east1-docker.pkg.dev/diamol2ees/ch14/hello-cloud, then deployed as a Cloud Run job or service. 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 command sequence to initialize gcloud, create a project, inspect billing accounts, link billing, and enable Artifact Registry. 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"

Continue the setup by creating a regional Docker repository, authenticating Docker, tagging an image with the project path, and pushing it. section 14.4

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

How deep it goes
Explains creation, billing linkage, service enablement, registry setup, and deployment workflows.
Examples
Uses hello-cloud and pi-web containers, the ch14 repository, regional image paths, and Cloud Run jobs or services.
What it assumes
Assumes a Google Cloud account and installed gcloud CLI, while demonstrating project preparation from the setup stage.
What you can do after
Operate a project with gcloud by linking billing, enabling services, and deploying container workloads.
How it connects
Connects projects with billing accounts, Artifact Registry, Cloud Run, containers, and the gcloud CLI.

Also explained in

Compare how 3 books explain GCP project →

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.