Deploying Docker Images To Google Cloud Using Kubernetes Engine

This post assumes that you already have a working docker image, that you can build and run on your local machine, and obviously a Google Cloud account with all of the necessary APIs activated, and the Google Cloud SDK installed on your machine. If all of that is in order, you are good to go!

The first thing I do is ensure that I have an up-to-date GitHub repo on my code, which I usually keep in the following format:

I set up a new repository in Github, and then make sure the repository is up to date using and before doing a final

Now, let’s get on and build our Docker image and push it up to Google Cloud’s container registry. Start by issuing:

Feel free to test in on your local machine with:

And kill / remove the process once you have finished using a combination of , , and .

Before pushing it to Google Cloud, we must quickly tag our image with the necessary information that Google Cloud needs. Make sure you replace with the correct project ID in the Google Cloud dashboard. Issue:

We can now push it to Google Cloud’s Container Registry using the command installed by the Google Cloud SDK. The registry is similar to Docker Cloud, but ties in nicely with Google’s console and the Kubernetes Engine. Push it with:

Now if you head to your Google Cloud Console, and over to the Container Registry, you should see your new Docker image there. Good work!

We now need to get our image served in Kubernetes Engine. Kubernetes Engine is Google’s hosted version of Kubernetes, which enables you to create a cluster of “nodes” to serve your containers among. To get started, create a cluster by following the prompts in the Kubernetes Engine dashboard. Then head to “workloads” and hit the “Deploy” button.

Make sure you click the “Select existing Google Container Registry image” button, and then choose your repository and tag (which will initially be v1). Click ‘Done’, give it a useful name, and then hit ‘Deploy’.

In the panel on the right, you will see the option to ‘Expose’ your image to the internet using a load balancer. Go ahead and do this. You will then be provided with an internet-facing endpoint which you can test your deployment on. Congratulations, you have just deployed a docker image to Google Cloud using Kubernetes Engine!



A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dr. Joe Logan

Developer and AI enthisiast from Sydney. Founder of Alixir. Check me out @