Want to deploy a web application but avoid server management and infrastructure configuration? Google Cloud Run is the perfect solution. Just provide a Docker container, and Cloud Run automatically handles scaling, HTTPS, and load balancing.

💡 Key Takeaway

Cloud Run is a "serverless container execution service." You're only billed when requests come in — zero traffic means zero cost. Even beginners can deploy in 15 minutes.

1. What is Cloud Run?

Cloud Run is Google's fully managed serverless container runtime. Unlike traditional serverless offerings (like Cloud Functions), its standout feature is the ability to run any language or framework as a container.

Key Features

  • Serverless: No infrastructure management, pay-per-request billing
  • Container-based: Docker-compatible, language/framework agnostic
  • Auto-scaling: Automatically adjusts from 0 to 1000 instances
  • Built-in HTTPS: Automatic SSL certificate management
  • Custom Domains: Easy custom domain configuration

Cloud Functions vs Cloud Run

  • Cloud Functions: Function-level deployment, language restrictions, ideal for lightweight tasks
  • Cloud Run: Container-level deployment, any language, ideal for full web applications

2. Environment Setup

Prerequisites

  1. A Google account (GCP free trial includes $300 in credits)
  2. Google Cloud SDK installed
  3. Docker installed
# Install Google Cloud SDK (macOS)
brew install --cask google-cloud-sdk

# Initial configuration
gcloud init

# Create a project
gcloud projects create my-cloudrun-app --name="My Cloud Run App"
gcloud config set project my-cloudrun-app

# Enable required APIs
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com

3. Your First Deployment

Let's deploy a simple Node.js web server to Cloud Run.

Step 1: Create the Application

// server.js
const express = require('express');
const app = express();
const port = process.env.PORT || 8080;

app.get('/', (req, res) => {
  res.json({
    message: 'Hello from Cloud Run! 🚀',
    timestamp: new Date().toISOString(),
    version: '1.0.0'
  });
});

app.get('/health', (req, res) => {
  res.status(200).json({ status: 'healthy' });
});

app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});

Step 2: Create a Dockerfile

# Dockerfile
FROM node:20-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]

Step 3: Deploy

# Deploy directly from source (auto-builds Docker image)
gcloud run deploy my-app \
  --source . \
  --region asia-northeast1 \
  --allow-unauthenticated

# Done! You'll see the URL
# Service URL: https://my-app-xxxxx-an.a.run.app
✅ Pro Tip

The --source . flag means you don't need to build locally — Cloud Build handles image creation automatically.

Ad

4. Pricing

Cloud Run uses pay-as-you-go pricing. No traffic = no charges.

Free Tier (Monthly)

  • 2 million requests free
  • CPU: 180,000 vCPU-seconds (~50 hours)
  • Memory: 360,000 GiB-seconds
  • Network: 1GB free within North America

For personal blogs or APIs, the free tier is more than sufficient. Even sites with tens of thousands of monthly page views often stay within the free tier.

⚠️ Caution

Using "always-on" CPU allocation mode incurs charges even during idle time. For cost optimization, use the default "request-only" mode.

5. Auto-Scaling

One of Cloud Run's biggest advantages is automatic scaling based on traffic.

How Scaling Works

  • Scale to zero: Instances shrink to 0 when there's no traffic
  • Horizontal scaling: Instances added as requests increase
  • Concurrency control: Limit concurrent requests per instance
# Configure min/max instances
gcloud run services update my-app \
  --min-instances 1 \          # Avoid cold starts
  --max-instances 100 \        # Cost control
  --concurrency 80 \           # Concurrent requests
  --region asia-northeast1

6. Practical Tips

Cold Start Mitigation

  • Set min-instances to 1: Keep one instance warm (~$5-10/month)
  • Use lightweight base images: node:20-slim or python:3.12-slim
  • Minimize startup processing: Defer initialization to request time

CI/CD Integration

Combine with GitHub Actions for automatic deployment on every push.

# .github/workflows/deploy.yml
name: Deploy to Cloud Run
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: google-github-actions/auth@v2
        with:
          credentials_json: ${{ secrets.GCP_CREDENTIALS }}
      - uses: google-github-actions/deploy-cloudrun@v2
        with:
          service: my-app
          region: asia-northeast1
          source: .

Cloud Run is the ideal service for "just get my container running." Free yourself from server management and focus on building your application. Start with a small project using the free tier!