Docker for AWS preview

Luis Herrera Benítez
3 min readJul 28, 2016

--

This new product was announced in the last DockerCon 2016 in Seattle (where else?) and is still in private beta. Docker for AWS is essentially an AWS CloudFormation configurable template which automatically provisions and configures a working Docker Swarm cluster on AWS. From there, you could use command line tools that let you deploy multi-container applications in the newly created environment. So, what’s the idea? Well, if you are a DevOps Engineer, and you don’t want to get into the nitty-gritty details of AWS, you could use the familiar Docker client command line to deploy your distributed and containerized apps in a breeze.

Let’s see it action. We first log in the AWS Console, and launch a CloudFormation template. Then we have to specify some details like the number the number of manager and worker nodes of our cluster (Docker terminology, you could get a definition of these terms here) and their instances types.

After few minutes, our cluster is up and running and CloudFormation outputs the name of our cluster manager.

and here we go:

$ ssh docker@Docker-ELB-SSH-151900366.us-east-1.elb.amazonaws.com -i ./Downloads/docker.pem
Welcome to Docker!
~ $ docker version
Client:
Version: 1.12.0-rc4
API version: 1.24
Go version: go1.6.2
Git commit: e4a0dbc
Built: Wed Jul 13 03:28:51 2016
OS/Arch: linux/amd64
Experimental: true
Server:
Version: 1.12.0-rc4
API version: 1.24
Go version: go1.6.2
Git commit: e4a0dbc
Built: Wed Jul 13 03:28:51 2016
OS/Arch: linux/amd64
Experimental: true

Now we check that CloudFormation has created the nodes that will compose our Docker Swarm Cluster:

~ $ docker node ls
ID HOSTNAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS
0hnxz094l56zlh6qo7br18v3i ip-192-168-34-110.ec2.internal Accepted Ready Active
1r7skqiqhpeuxo1d3vl2dqz7x ip-192-168-33-145.ec2.internal Accepted Ready Active
3z7405x6dlpscl8904if9at2w ip-192-168-33-249.ec2.internal Accepted Ready Active Reachable
55f8do92ezbealxpx4a175swa ip-192-168-34-111.ec2.internal Accepted Ready Active
5p5z3e8ntaidx588fn7kkbqlq * ip-192-168-34-171.ec2.internal Accepted Ready Active Reachable
7tf5re58ga2io4oiteifxyfyr ip-192-168-34-112.ec2.internal Accepted Ready Active
7wo8itwr783pu93anv2oe7xla ip-192-168-34-170.ec2.internal Accepted Ready Active Leader
eygbdc203srwlea1e58elg203 ip-192-168-33-146.ec2.internal Accepted Ready Active

Once we check all is ok, we create a global service. Global services launch a container on each active node of a cluster:

~ $ docker service create --name helloworld --mode global --publish 80:80 nginx
bb8itaxvjpc3dfo70tscgv5kk

Now we list all of the task (containers) that are running as part of the specified service:

~ $ docker service tasks helloworldID                         NAME        SERVICE     IMAGE  LAST STATE          DESIRED STATE  NODE
1ohhjbe0pkfneuwcjypgz2zjl helloworld helloworld nginx Running 34 seconds Running ip-192-168-33-146.ec2.internal
d1u279e6dlq6u4rl29wavuqw8 helloworld helloworld nginx Running 34 seconds Running ip-192-168-34-110.ec2.internal
2ql9s21hhgzbzifr8gkiw3y0y helloworld helloworld nginx Running 34 seconds Running ip-192-168-34-112.ec2.internal
d8oru12sndkvyfu0p3nao5mte helloworld helloworld nginx Running 34 seconds Running ip-192-168-34-111.ec2.internal
927arww0uefjvbakl8kctwlb6 helloworld helloworld nginx Running 34 seconds Running ip-192-168-33-145.ec2.internal
100xmmgg9bd09821nq37u42qu helloworld helloworld nginx Running 34 seconds Running ip-192-168-34-171.ec2.internal
11qzy9jzuozx05vqxpg8j5s61 helloworld helloworld nginx Running 34 seconds Running ip-192-168-33-249.ec2.internal
0xlseyusuwnw8k4mvyiu6h6zk helloworld helloworld nginx Running 34 seconds Running ip-192-168-34-170.ec2.internal

And all the services running on our cluster…in this case just “helloworld”

~ $ docker service ls
ID NAME REPLICAS IMAGE COMMAND
bb8itaxvjpc3 helloworld global nginx

The CloudFormation creates a configure a number of AWS resources during the initial setup, including including an AWS Elastic Load Balancer. And that happens to be forwarding traffic on port 80 to all the nodes, on the same port. So, if we use the URL provided by the template…

~ $ wget -O- Docker3-ELB-180571294.us-east-1.elb.amazonaws.com 2>&1 | head -1
Connecting to Docker3-ELB-180571294.us-east-1.elb.amazonaws.com (52.207.20.161:80)
~ $ wget -O- Docker3-ELB-180571294.us-east-1.elb.amazonaws.com 2>&1 | head -1
Connecting to Docker3-ELB-180571294.us-east-1.elb.amazonaws.com (52.3.89.201:80)

and voilá!. We get traffic routed and distributed among the different tasks in our cluster.

--

--

Luis Herrera Benítez

AI & Big Data aficionado. Redis enthusiast. Xoogler. Fomer Docker Captain and AWS Ambassador. Everybody has a plan until they get punched in the face.