Deploy Java Blog to Cloud Run | Generated by AI

Home 2026.02

Question: How to use a Docker container to deploy the blog-server application in Google Cloud?

Answer:

Here are the most common and recommended ways in 2026 to deploy your Dockerized Java/Spring Boot application (from the directory with Dockerfile and pom.xml) to Google Cloud. The easiest and most popular option today is Cloud Run (serverless containers).

You don’t even need to build the Docker image locally.

  1. Make sure you have the Google Cloud SDK installed and authenticated:
    gcloud auth login
    gcloud config set project YOUR-PROJECT-ID
    
  2. Enable necessary APIs (run once):
    gcloud services enable run.googleapis.com artifactregistry.googleapis.com cloudbuild.googleapis.com
    
  3. From the project root (where pom.xml and Dockerfile are), run:
    gcloud run deploy blog-server \
      --source . \
      --region asia-northeast1 \          # or us-central1, europe-west1, etc.
      --allow-unauthenticated \          # remove if you want private service
      --port 8080 \                      # change if your app listens on different port
      --memory 1Gi                       # optional – adjust based on needs
    
    • Cloud Run automatically detects it’s a Maven/Spring Boot project, builds a container using Cloud Build, and deploys it.
    • First deployment takes ~3–5 minutes; later ones are much faster.

Option B – Build Docker image yourself and push it

Useful when you want more control or already have CI/CD.

  1. Build and tag the image locally:
    docker build -t gcr.io/YOUR-PROJECT-ID/blog-server:latest .
    # or use Artifact Registry (newer & recommended):
    # docker build -t asia-northeast1-docker.pkg.dev/YOUR-PROJECT-ID/my-repo/blog-server:latest .
    
  2. Push the image:
    gcloud auth configure-docker
    docker push gcr.io/YOUR-PROJECT-ID/blog-server:latest
    # or for Artifact Registry:
    # gcloud auth configure-docker asia-northeast1-docker.pkg.dev
    # docker push asia-northeast1-docker.pkg.dev/YOUR-PROJECT-ID/my-repo/blog-server:latest
    
  3. Deploy to Cloud Run:
    gcloud run deploy blog-server \
      --image gcr.io/YOUR-PROJECT-ID/blog-server:latest \
      --region asia-northeast1 \
      --allow-unauthenticated \
      --port 8080
    

    Or using Artifact Registry image:

    --image asia-northeast1-docker.pkg.dev/YOUR-PROJECT-ID/my-repo/blog-server:latest
    

Quick checklist before deploying

Cloud Run is usually the best balance of price, simplicity, and scaling for a blog server.

After deployment you will get a URL like:

https://blog-server-abc123-uc.a.run.app

Good luck!

References:


Back Donate