In this hands-on lab, you’ll familiarize yourself with Cloud Run, both in the web Cloud Console and via the command line in Cloud Shell. You’ll deploy a Hello World container image to Cloud Run, and then import a public image from Docker Hub to create a second Cloud Run service.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Configure the Environment
Configure the
gcloud
SDK for Cloud Run, and get your environment ready to deploy.- Set the default platform to
managed
. - Choose a default region.
- Configure Docker authentication for
gcloud
. - Enable the Cloud Run API for your project. Set the minimum number of instances as 0, and set the maximum number as 1.
Note: Once you viewed the URL, select the Cloud Run deployment and choose DELETE.
- Set the default platform to
- Deploy Hello World Containers
Once the environment is set up, deploy some Hello World containers. You can use the demo container provided by Cloud Run.
- Deploy a Hello World service via the Cloud Console.
- Deploy a Hello World service via the command line using
gcloud
. When using thegcloud run deploy
command, make sure to use the--cpu=2 --max-instances=1 --memory=4Gi
options.
The container image location is:
gcr.io/cloudrun/hello
Note: Once you viewed the URL, select the Cloud Run deployment and choose DELETE.
- Deploy a Public Docker Image to Cloud Run
Finally, let’s grab a public Docker image and deploy it to Cloud Run.
- Pull a public Docker image to your local registry in the Cloud Shell.
- Tag the image for Google Container Registry.
- Push the image to Google Container Registry.
- Deploy a service in Cloud Run using the new image.
You can use any Docker image you like that exposes a web service. By default, that service should be running on port 8080, but this is configurable in Cloud Run. If you’d like to use the HTTP Doom image from the videos, it can be found in Docker hub here:
mattipaksula/http-doom
Note: Once you viewed the URL, select the Cloud Run deployment and choose DELETE.