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.
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
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):
Connecting to the Docker VM instances can also be done via
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.
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.
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.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.
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
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).
Docker Community & Slack:
Docker Cloud & Swarm Mode Fleet Management: