Getting Started with Cloud Run

Photo by Sigmund on Unsplash

Getting Started with Cloud Run


Cloud Run is a serverless platform developed by Google that allows developers to deploy and run containerized applications without having to manage infrastructure. With Cloud Run, you can deploy applications built using any programming language or framework, as long as they can run inside a Docker container. In this blog post, we'll go over some basics and get you started with Cloud Run.

What is Cloud Run?

Cloud Run is a fully managed compute platform that automatically scales your containerized applications. It takes care of the underlying infrastructure so you can focus on building and deploying your applications. With Cloud Run, you only pay for the exact amount of resources your application needs to run. This makes it a cost-effective solution for many use cases.

How to Get Started with Cloud Run

Getting started with Cloud Run is easy. Here's a quick overview of the steps you'll need to follow:

  1. Sign up for a Google Cloud account if you haven't already.

  2. Install the Google Cloud SDK and set up your local development environment.

  3. Build and containerize your application.

  4. Deploy your application to Cloud Run using the gcloud command-line tool.

Once you've set up your local development environment, you can start building your application. You can use any programming language or framework as long as it can run inside a Docker container. In this example, we'll use Node.js.

Example: Node.js App

Here's an example of a simple Node.js app that you can deploy to Cloud Run:

const express = require('express')
const app = express()

app.get('/', (req, res) => {
  res.send('Hello, Cloud Run!')

const port = process.env.PORT || 8080
app.listen(port, () => {
  console.log(`App listening on port ${port}`)

To containerize this app, you'll need to create a Dockerfile:

FROM node:14
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "start" ]

Once you've created the Dockerfile, you can build the container:

docker build -t my-node-app .

And then deploy the container to Cloud Run:

gcloud run deploy --image[PROJECT-ID]/my-node-app --platform managed

Replace [PROJECT-ID] with your project ID.


Cloud Run is a powerful platform that makes it easy to deploy and run containerized applications. With its automatic scaling and cost-effective pricing model, it's a great choice for many use cases. If you're new to Cloud Run, hopefully, this blog post has given you a good introduction to the platform and how to get started. Happy coding!

Did you find this article valuable?

Support Gayan Hewa by becoming a sponsor. Any amount is appreciated!