Ever feel like you’re stuck with old technologies? Today, businesses are shifting their apps to the cloud. They do this for better performance, more scalability, and cost savings. But what about legacy applications? Many businesses depend on ‘legacy-applications’ – Those are reliable, monolithic systems were built long before cloud technologies were popular. You can modernize these apps and get the benefits of the cloud. One of the best ways to do this is by using containers and Google cloud Run.
In this blog, we will explain why containerizing legacy applications makes sense. We’ll also show you how to do it step by step. Plus, we’ll highlight the benefits of using Cloud Run.
Why use containers?
Think of a container as a lightweight package for your application. It includes everything the app needs to run: the code, settings, and any supporting dependencies/files. This makes it super portable.
Why Containerize a Legacy Application?
Most legacy applications were designed to run on traditional servers, which makes scaling, updating, or deploying them efficiently difficult. Containerization solves these problems by:
- Easy Scaling: Containers allow you to easily create copies of your app, handle increased traffic and scale up or down based on demand. No more server headaches!
- Simple Deployment: Moving the entire application with its dependencies into a single unit to a new environment becomes an easy job. This way, everything’s nicely packaged, it runs the same everywhere, reducing those frustrating “it works on my machine” moments.
- Cost Savings: Cloud Run is a serverless platform. This means you only pay when your app is running. This way you can reduce the cost of always-on servers!
- Enhanced Security: Containers provide isolation, by reducing the risk of other applications and other parts of your system affecting your legacy app.
- New Features: When applications are containerized, they can connect and use the new cloud services like – modern databases, security, networking, and app management tools.
Steps to Containerize Legacy Applications for Cloud Run



Step 1: Analyze Your App
Before you start containerizing your legacy application, you need to understand its architecture. Figure out:
- What programming language is it written in? (Java, Python, .NET, etc.)
- What dependencies does it have? (Database connections, libraries)
- Does it have specific OS configurations?
- Where does it store data? (Persistent storage or local files)
If your application depends heavily on the operating system, a multi-stage build may be necessary to keep the container lightweight.
Step 2: Create a Docker file
A Docker file is a script it tells Docker how your application should be pack into a container. Here’s an example for your Java-based legacy application:
Dockerfile:
FROM openjdk:17-jdk-slim # Use a small, efficient Java image
WORKDIR /app # Set the working directory inside the container
COPY target/my-legacy-app.jar my-legacy-app.jar # Copy your app's code
CMD ["java", "-jar", "my-legacy-app.jar"] # Command to run your app
For Java applications built with Spring Boot, you might need to add some more configurations to your Dockerfile to ensure your application’s ports are accessible from outside the container. This is because Spring Boot apps often run on a specific port (by default, 8080), and you need to make sure that port is expose correctly when the app is running inside a Docker container.
Step 3: Build and Test Your Container Locally
Once your Docker file is ready, build and test your container on your own machine to make sure everything works:
Bash:
docker build -t my-legacy-app. # Build the container image
docker run -p 8080:8080 my-legacy-app # Run the container
Step 4: Upload your container image to Google Container Registry (GCR).
Cloud Run requires your container image to be store in a registry. You can use Google Container Registry (GCR) or Artifact Registry:
gcloud auth configure-docker # Connect to your Google Cloud account
docker tag my-legacy-app gcr.io/YOUR_PROJECT_ID/my-legacy-app #Tag the container image
docker push gcr.io/YOUR_PROJECT_ID/my-legacy-app # Upload it to GCR
Step 5: Deploy on Cloud Run
Finally, deploy your containerized appl to Cloud Run:
gcloud run deploy my-legacy-app \
--image gcr.io/YOUR_PROJECT_ID/my-legacy-app \
--platform managed \
--region us-central1 \
--allow-unauthenticated
Cloud Run takes care of the rest, giving you a live, scalable app accessible over the internet.
Benefits of Running Containerize Legacy Applications on Cloud Run
- No Server Management – Google manages all the servers, so you can focus on your app, not on infrastructure.
- Pay-as-you-go – Only pay for the resources your app actually uses. Cloud Run charges only for the exact CPU and memory your application uses.
- Better Performance – Your legacy app can take advantage of Google’s high-speed network and powerful infrastructure.
- Security & Compliance – Built-in security features like IAM, automatic HTTPS, and DDoS protection.
- Easy Connections – Integrate your app with other Google Cloud services.
Conclusion
Containerize Legacy Applications doesn’t need to completely rewrite them from scratch. It means packaging them in a way that makes them more portable, scalable, and cost-effective. Deploying your containerized application on Cloud Run modernizes your infrastructure. You can still use your existing codebase.
















