Docker Swarm

Clusters Abound

signup!

getcarina.com

mycluster.rackspace.com

Login Please!

Login!

Create a cluster!

β›΅

β›΅

Cluster built!

πŸŽ‰

πŸŽ‰

Grow it

Swarm

  • Many Docker Hosts, one API endpoint
  • New primitives (e.g. affinities)
  • Scheduling according to resource constraints

Get your Docker environment

1

2

$ ls
boatboat.zip
$ unzip boatboat.zip
Archive:  boatboat.zip
 extracting: boatboat/ca.pem
 extracting: boatboat/README.md
 extracting: boatboat/ca-key.pem
 extracting: boatboat/docker.cmd
 extracting: boatboat/docker.env
 extracting: boatboat/docker.ps1
 extracting: boatboat/cert.pem
 extracting: boatboat/key.pem
$ cd boatboat/
$ source docker.env
$ docker version
Client version: 1.6.1
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 97cd073
OS/Arch (client): darwin/amd64
Server version: swarm/0.4.0
Server API version: 1.16
Go version (server): go1.4.2
Git commit (server): d647d82
OS/Arch (server): linux/amd64
$ source docker.env
$ 
$ docker run -d -p 80:8080 --name whoa rackerlabs/whoa
44aff6801d136ae7ba49ad074d94a7ba94740326f8d9099d7830ec8095abdf72

whoa

80

Problems?

Get DVM, the Docker Version Manager

Β 

github.com/getcarina/dvm

$ docker run -d -p 80:8080 --name whoa rackerlabs/whoa
44aff6801d136ae7ba49ad074d94a7ba94740326f8d9099d7830ec8095abdf72
$ # Get a new Docker client
$ alias docker='./docker-1.6.1'
$ docker rm whoa

whoa

80

$ docker run -d -p 80:8080 --name whoa rackerlabs/whoa
44aff6801d136ae7ba49ad074d94a7ba94740326f8d9099d7830ec8095abdf72
$ docker port whoa 8080
104.130.0.119:80
$ curl 104.130.0.119:80
πŸŽ‰ Whoa! πŸŽ‰

whoa

80

104.130.0.119

$ docker run -d -p 80:8080 --name whoa rackerlabs/whoa
44aff6801d136ae7ba49ad074d94a7ba94740326f8d9099d7830ec8095abdf72
...
$ # Now for another web head
$ docker run -d -p 80:8080 --name whoa2 rackerlabs/whoa
5e0a9815f9558c7a26a44f3bb214f241a5fbf26e01e008739dff64e39c802fce
$ docker port whoa2 8080
104.130.0.117:80
$ curl 104.130.0.117:80
πŸŽ‰ Whoa! πŸŽ‰

whoa

80

104.130.0.119

104.130.0.117

whoa

80

Exercise:

LaunchΒ more but using the `whoa/tiny` image onΒ portΒ 8080

$ docker run -d -p 80:8080 --name whoa rackerlabs/whoa
44aff6801d136ae7ba49ad074d94a7ba94740326f8d9099d7830ec8095abdf72
...
$ # Now for another web head
$ docker run -d -p 80:8080 --name whoa2 rackerlabs/whoa
5e0a9815f9558c7a26a44f3bb214f241a5fbf26e01e008739dff64e39c802fce
$ # AND AGAIN?!?
$ docker run -d -p 80:8080 --name whoa3 rackerlabs/whoa
FATA[0000] Error response from daemon: unable to find a node
with port 80 available

whoa

80

104.130.0.119

104.130.0.117

whoa

80

$ docker ps # Your results will differ ;)
PORTS                        NAMES
104.130.0.117:80->8080/tcp   7b0948a3-d660-465a-b32d-5051c25184ba-n1/whoa2
104.130.0.119:80->8080/tcp   7b0948a3-d660-465a-b32d-5051c25184ba-n2/whoa

whoa

80

104.130.0.119

104.130.0.117

whoa

80

Exercise:
Swarm &
RSΒ LBs

$ docker info
Containers: 9
Images: 7
Storage Driver:
Role: primary
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 2
 7b0948a3-d660-465a-b32d-5051c25184ba-n1: 104.130.0.117:42376
  β”” Containers: 5
  β”” Reserved CPUs: 0 / 12
  β”” Reserved Memory: 0 B / 2.1 GiB
  β”” Labels: executiondriver=native-0.2, kernelversion=3.12.36-2-rackos, operatingsystem=Debian GNU/Linux 7 (wheezy) (containerized), storagedriver=aufs
 7b0948a3-d660-465a-b32d-5051c25184ba-n2: 104.130.0.119:42376
  β”” Containers: 4
  β”” Reserved CPUs: 0 / 12
  β”” Reserved Memory: 0 B / 2.1 GiB
  β”” Labels: executiondriver=native-0.2, kernelversion=3.12.36-2-rackos, operatingsystem=Debian GNU/Linux 7 (wheezy) (containerized), storagedriver=aufs
Execution Driver:
Kernel Version:
Operating System:
CPUs: 24
Total Memory: 4.2 GiB
Name: 1d724f443821
ID:
Http Proxy:
Https Proxy:
No Proxy:
$ docker info
Containers: 9
Images: 7
Storage Driver:
Role: primary
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 2
 7b0948a3-d660-465a-b32d-5051c25184ba-n1: 104.130.0.117:42376
  β”” Containers: 5
  β”” Reserved CPUs: 0 / 12
  β”” Reserved Memory: 0 B / 2.1 GiB
  β”” Labels: executiondriver=native-0.2, kernelversion=3.12.36-2-rackos, operatingsystem=Debian GNU/Linux 7 (wheezy) (containerized), storagedriver=aufs
 7b0948a3-d660-465a-b32d-5051c25184ba-n2: 104.130.0.119:42376
  β”” Containers: 4
  β”” Reserved CPUs: 0 / 12
  β”” Reserved Memory: 0 B / 2.1 GiB
  β”” Labels: executiondriver=native-0.2, kernelversion=3.12.36-2-rackos, operatingsystem=Debian GNU/Linux 7 (wheezy) (containerized), storagedriver=aufs
Execution Driver:
Kernel Version:
Operating System:
CPUs: 24
Total Memory: 4.2 GiB
Name: 1d724f443821
ID:
Http Proxy:
Https Proxy:
No Proxy:

whoa

104.130.0.117

whoa

104.130.0.119

# of

Containers

Running?

$ docker info
Containers: 9
Images: 7
Storage Driver:
Role: primary
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 2
 7b0948a3-d660-465a-b32d-5051c25184ba-n1: 104.130.0.117:42376
  β”” Containers: 5
  β”” Reserved CPUs: 0 / 12
  β”” Reserved Memory: 0 B / 2.1 GiB
  β”” Labels: executiondriver=native-0.2, kernelversion=3.12.36-2-rackos, operatingsystem=Debian GNU/Linux 7 (wheezy) (containerized), storagedriver=aufs
 7b0948a3-d660-465a-b32d-5051c25184ba-n2: 104.130.0.119:42376
  β”” Containers: 4
  β”” Reserved CPUs: 0 / 12
  β”” Reserved Memory: 0 B / 2.1 GiB
  β”” Labels: executiondriver=native-0.2, kernelversion=3.12.36-2-rackos, operatingsystem=Debian GNU/Linux 7 (wheezy) (containerized), storagedriver=aufs
Execution Driver:
Kernel Version:
Operating System:
CPUs: 24
Total Memory: 4.2 GiB
Name: 1d724f443821
ID:
Http Proxy:
Https Proxy:
No Proxy:

whoa

104.130.0.117

whoa

104.130.0.119

$ docker ps -a
IMAGE                    COMMAND                PORTS                                    NAMES
rackerlabs/whoa:latest   "/whoa"                104.130.0.117:80->8080/tcp               7b0948a3-d660-465a-b32d-5051c25184ba-n1/whoa2
rackerlabs/whoa:latest   "/whoa"                104.130.0.119:80->8080/tcp               7b0948a3-d660-465a-b32d-5051c25184ba-n2/whoa
cirros:latest            "/bin/bash"                                                     7b0948a3-d660-465a-b32d-5051c25184ba-n1/goofy_hoover
swarm:latest             "/swarm manage -H=tc   2375/tcp, 104.130.0.119:2376->2376/tcp   7b0948a3-d660-465a-b32d-5051c25184ba-n2/swarm-manager
swarm:latest             "/swarm join --addr=   2375/tcp                                 7b0948a3-d660-465a-b32d-5051c25184ba-n2/swarm-agent
cirros:latest            "/sbin/init"                                                    7b0948a3-d660-465a-b32d-5051c25184ba-n2/swarm-data
swarm:latest             "/swarm manage -H=tc   2375/tcp, 104.130.0.117:2376->2376/tcp   7b0948a3-d660-465a-b32d-5051c25184ba-n1/swarm-manager
swarm:latest             "/swarm join --addr=   2375/tcp                                 7b0948a3-d660-465a-b32d-5051c25184ba-n1/swarm-agent
cirros:latest            "/sbin/init"                                                    7b0948a3-d660-465a-b32d-5051c25184ba-n1/swarm-data

What are those?

(whiteboard time)

Exercise:

Launch theΒ `whoa/tiny` image with constraints.

Made with Slides.com