The contents of this site are my personal thoughts, works, and opinions and do not reflect those of my current or previous employers.

Simple Container Deploys on Google Cloud Platform

Google has been working with containers internally since 2003. In 2006 they introduced cgroups to the linux kernel. Kubernetes and GKE are introduced to the world in 2014. Today Google deploys 4 billion containers every week. Containers are in Google’s DNA. Users of the Google Cloud Platform get access to this as well across GCP’s computing ecosystem.

Containers are being adopted and a significant rate across enterprises and Kubernetes has pretty much become a household name now, so why look at other ways to deploy containers? Many organizations are in the process of modernizing their architectures. Some applications are getting rewritten from scratch and some need to just work. Kubernetes brings a bunch of great capabilities for modern apps, but enterprises can get a lot of efficiency by just moving to containers too.

A common first step for organizations is to explore containers, to Dockerize a few apps they have. Maybe the infrastructure team is comfortable with VMs and not ready for GKE. Dev and platform teams are able to package up an app in a container and run it on VMs in one easy step. The infrastructure can change later.

Or maybe teams just need to be able to get new apps out the door quickly and don’t want to worry about infrastructure at all. Pushing containers to a PaaS or Serverless allows a hands off approach today, but allows the flexibility to move the apps to a more managed platform when the need arises.

In the following demo we’ll walk through deploying the same sample container to the various Google Cloud compute platforms including Google Compute Engine, Google App Engine, Cloud Run, and Google Kubernetes Engine, with just a few commands.

Let’s jump in and do some deploys

Before you begin

First time GCP setup

If this is your first time using GCP you’ll need to get things setup before you jump into the demo. Setup a GCP Project Create a GCP project Download, install, and initialize the Cloud SDK. Acquire local credentials for authenticating with GCP services.

gcloud auth application-default login

Verify that your default project is correct.

gcloud config list

If the project ID listed in the output isn’t the project that you intended to use for this tutorial, set the project.

gcloud config set project [YOUR_PROJECT_ID]

where [YOUR_PROJECT_ID] is the ID of the project that you created or chose to use for this tutorial.

Prepare the Demo

Configure some defaults

gcloud config set compute/zone us-central1-a
gcloud config set run/region us-central1

Clone the sample repository.

git clone
cd hello-python-container

Alternatively, you can download the sample as a zip file and extract it.

Build the sample app and push the container to the registry

export PROJECT=$(gcloud config get-value project)
gcloud builds submit --tag${PROJECT}/hellopython

Containers on Compute Engine

If you have any experience with Virtual Machines or Cloud IaaS this may seem obvious that you can install docker and run containers.

However it’s even easier than that on GCP. Google Compute Engine allows you to deploy an image directly to a traditional VM with a single command.

Deploy a container to GCE in one command

gcloud compute instances create-with-container hellopython \

Containers on GKE

Google’s flagship managed kubernetes service GKE has been around for nearly 4 years and of course can run containers simply and easily.

Create your cluster in less than 5 minutes with a simple command

gcloud container clusters create mycluster

Then deploy your container again with one command

kubectl run hellopython --image${PROJECT}/hellopython 

Containers on AppEngine

The AppEngine Flex runtime supports custom runtimes through the use of containers. Typically you would provide source code and a Dockerfile which would be built into an image for you and subsequently deployed.

However you may not know you can deploy images directly with app engine

We do need a very simple app.yaml

cat <<EOF >> app.yaml
runtime: custom
env: flex

Now deploy an image in one command

gcloud app deploy \

Containers on Cloud Run

Cloud Run is a managed compute platform that enables you to run stateless containers invocable via HTTP requests. Cloud Run is serverless: it abstracts away all infrastructure management, so you can focus on what matters most — building great applications.

You have to try this demo for yourself it’s fantastic

Deploy your app to Cloud Run in one command

gcloud beta run deploy hellopython \
    --image${PROJECT}/hellopython \

In just a moment your service is up and running with a secured https endpoint.

Super fast super simple


Containers are becoming a staple of modern systems and migrating to containers is often a great choice. Taking advantage of the many runtime options available, you can deploy your containers to meet the unique workload needs.