Deploying Containers to Cloud Run in <5mins

Cloud Run is now Generally Available. Read more here


Software developers today can focus on building applications faster without having to bother about how their codes run on other environments, this is because containerization takes care of bundling applications along with their configuration and dependencies into an efficient way of running it across different environments.


Deploying Containers (Docker or Kubernetes) can also be a headache when you also have to take care of provisioning the underlying infrastructure, however, Google Cloud provides a way for you to deploy containerized applications to the cloud in a serverless fashion called Cloud Run, it abstracts away the underlying infrastructure, runs and auto-scales your stateless application automatically.

In this article, we’ll briefly build and deploy a containerized application and deploy to Cloud Run.

Before you begin:

Build and Publish Container Images

Cloud Build allows us to build Docker images on the Cloud, all we need is our project files (which includes a Dockerfile).

The following command runs on Cloud Shell to build our Docker image and push the image to Container Registry.

gcloud builds submit --tag<PROJECT_ID>/demo-image .</span>

Replace <PROJECT_ID> with your actual project ID value.

Note that if you’re building larger images, you can pass a timeout parameter such as: _--timeout=600s_

Deploy to Cloud Run

We would go-ahead to deploy our image from Cloud Shell using the following command:

gcloud beta run deploy demo-app --image<PROJECT_ID>/demo-image --region us-central1 --platform managed --allow-unauthenticated --quiet</span>

Boom! The application container has been deployed to Cloud Run.😀

Cloud Run is worth looking into by teams, it provides affordability, security, isolation, flexibility by allowing deployment to a Kubernetes cluster (Cloud Run for Anthos) and a lot more.

Here’s a short demo of how fast it is to deploy and access containers with Cloud Run.

Another short demo of deploying directly to Cloud Run from your Git repository using the Cloud Run Button.

Check out some more Additional Resources on Cloud Run :

Thanks for reading through! Let me know if I missed any step, if something didn’t work out quite right for you or if this guide was helpful.

Comments (1)

Max Voitko's photo

Hi! Is it possible to run serverless background tasks in Google Cloud Platform? I mean smth like AWS Fargate?