Your First Cloud Run Deployment

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

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.

  1. Set the default platform to managed.
  2. Choose a default region.
  3. Configure Docker authentication for gcloud.
  4. 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.
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.

  1. Deploy a Hello World service via the Cloud Console.
  2. Deploy a Hello World service via the command line using gcloud. When using the gcloud 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.

  1. Pull a public Docker image to your local registry in the Cloud Shell.
  2. Tag the image for Google Container Registry.
  3. Push the image to Google Container Registry.
  4. 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.

Additional Resources

Log in to Google Cloud Platform by right-clicking Open Google Console and selecting the option to open it in a new private browser window (this option will read differently depending on your browser — e.g., in Chrome, it says "Open Link in Incognito Window"). Then, sign in using the credentials provided on the lab page.

On the Welcome to your new account screen, review the text, and click Accept. In the "Welcome Cloud Student!" pop-up once you're signed in, check to agree to the terms of service, choose your country of residence, and click Agree and Continue.

To prevent the lab from shutting down: When setting up Cloud Run, set the minimum number of instances as 0, and set the maximum number as 1.

When using the gcloud run deploy command, make sure to use the --cpu=2 --max-instances=1 --memory=4Gi options.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?