Testing Docker for GCP hands-on - Part 1 Basic Setup

Update: As Kubernetes seems to have "won" the "battle" for container orchestration this project will probably not be continued. For container management on Google Cloud check out Google Kubernetes Engine.

As with Docker for AWS and Docker for Azure which are meanwhile GA and ready for production, Docker now also offers a beta of Docker for Google Cloud Plattform which is, at the time of writing, only recommended for development and testing. This post shows a basic setup and its outcomes.

GCP provides a free trial of $300 for 12 months.

Tested version of Docker for GCP is v9 ... see the release notes for further info.

Installation

Following the instructions here you just need one command to create a Swarm cluster (using Google Cloud Shell after selecting your Google Cloud Project in GCP Console):

gcloud deployment-manager deployments create docker \ --config https://download.docker.com/gcp/edge/Docker.jinja \ --properties managerCount:3,workerCount:1

There are also other configuration options available, like e.g. zones:

--properties managerCount:3,workerCount:1,zone:europe-west1-b

Outcomes

GCP Console Dashboard

After lesss then five minutes you can view your VM instances in the dashbord:

With this default setup also the following disks are created:

A healthcheck (heart beat) comes out-of-the-box, too:

The setup creates a dedicated VPC subnet called "docker-network":

GCP provides you with one (permanently static) external IP address (load balancer) ... all other instances also have public external ip addresses which might change:

The load balancer is set up as follows:

And according firewall rules (for incoming traffic):

CLI

Connecting to the Docker VM instances can also be done via gcloud:

gcloud compute --project "<project_id>" ssh --zone "us-central1-f" "docker-manager-1"

On first connect you will be prompted if you wish the keys to be auto-created (alternatively you can provide your own project-wide keys in the project's metadata section). You can also connect via standard ssh.

You can also combine Docker Cloud and Docker for Mac|Windows with Docker for GCP through Swarm Fleet Management giving you an "all-arround" connectivity. Still in beta, still for free.

A docker ps and a docker node ls show the following:

The outputs for docker network ls and docker volume ls

There is also the option for runnning a docker-diagnose command for debugging purposes.

Uninstalling

In order to remove this setup you first need to delete the instances:

gcloud compute instances delete --delete-disks=boot $(gcloud compute instances list --filter='networkInterfaces[0].network ~ docker-network' --uri)

And then the deployment itself:

gcloud deployment-manager deployments delete docker

This will remove everything from above except the manager's data disks. If wished, these can be deleted e.g. via the dashboard.

The Google Cloud Project itself in the dashboard will of course remain.

Summary

That is it ... your one-command datacenter (clustered and fault-tolerant). Of course, this is "only" a datacenter in a datacenter (with classic VMs underneath on shared infrastructure) and of course this is only a very basic setup, but it is amazing that it is possible at all.

The basic setup and its components felt more intuitive than with Docker for AWS which appeared at first glance rather complicated and maybe even over-engineered - at least if not familiar with AWS. Also the GCP Console, its dashboard, and gcloud/Google Cloud Shell did make a good, responsive, and intuitively ordered impression.

Of course the obligatory nginx example (run unmanaged from Swarm via a simple docker run) worked as expected and the port host mapping made it directly available on the static external IP address ... and removed it after stopping the container. A port scan later on did not reveal any open ports on the static external IP.

Go ahead give it a try ... you can use the pricing calculator to get an estimate what it will cost based on the outcomes above. Estimated charges before taxes for this basic setup running for ca. 48h were a little more than 7 EUR. Most of which was for the instances, but network load balancing is also charged (depending on the amount of rules and traffic).

Further Information

Docker for GCP Docs:

https://beta-stage.docker.com/docs/gcp/

https://beta-stage.docker.com/docs/deploy/

https://beta-stage.docker.com/docs/gcp/release-notes/

https://beta-stage.docker.com/docs/faq/

GCP Docs:

https://cloud.google.com/compute/docs/instances/connecting-to-instance#standardssh

https://cloud.google.com/products/calculator/

Docker Announcement:

https://blog.docker.com/2017/03/beta-docker-community-edition-google-cloud-platform/

https://www.youtube.com/watch?v=Fk2HeCxKGgk

Docker Community & Slack:

https://blog.docker.com/2016/11/introducing-docker-community-directory-docker-community-slack/

Docker Cloud & Swarm Mode Fleet Management:

https://blog.docker.com/2017/03/swarm-mode-fleet-management-collaboration-now-public-beta-powered-docker-cloud/

https://docs.docker.com/docker-cloud/cloud-swarm/

Docker Captain @ajeetsraina on "Getting Started with LinuxKit for Google Cloud Platform":

http://collabnix.com/archives/2929