The container abstraction hit the collective developer mind with great force and created a space of innovation for the distribution, configuration and deployment of cloud based applications. Now that this new model has established itself work is moving towards orchestration and coordination of loosely coupled network services. There is an explosion of tools in this arena at different degrees of stability but the momentum is huge.
On the above premise this session we'll delve into a selection of the following topics:
- Two minute Docker intro refresher
- Overview of the orchestration landscape (Kubernetes, Mesos, Helios and Docker tools)
- Introduction to Docker own ecosystem orchestration tools (machine, swarm and compose)
- Live demo of cluster management using a sample application.
A basic understanding of Docker is suggested to fully enjoy the talk.
5. 5
DEFINITIONS
Seen from another angle, the core of
Docker is four distinct things
Clearly defined
interfaces
Central registry of
ready images
Caching mechanism
to re-use steps
A standard format to
package applications
6. 6
DO WE USE IT?
We have embraced Docker on two fronts
For our internal PaaS In our products
NOT PART OF THIS
SESSION
21. 20
TOOL NR.1
Docker machine
Simple command line tool to provision local
and remote hosts with Docker installed.
Fantastic to get up and running fast. It has
drivers for many Internet service providers
and PaaS.
Docker machine
$ docker-machine create -d v
INFO[0000] Downloading boot2
INFO[0001] Creating SSH key.
INFO[0001] Creating VirtualB
INFO[0006] Starting VirtualB
INFO[0007] Waiting for VM to
INFO[0041] "dev" has been cr
22. • Provision a machine with
Docker installed and ready
• Pull a minimal image
• Run a few docker commands
• Tear down the machine
Docker machine DEMO
$ docker-machine create -d virtualb
INFO[0000] Downloading boot2docker.
INFO[0001] Creating SSH key...
INFO[0001] Creating VirtualBox VM..
INFO[0006] Starting VirtualBox VM..
INFO[0007] Waiting for VM to start.
INFO[0041] "dev" has been created a
23. • “docker-machine create” to provision the host, locally or remotely
• “docker-machine ls” to list the machines
• “docker-machine stop/rm” to stop and remove
Recap of what you saw
$ docker-machine create -d
INFO[0000] Downloading boo
INFO[0001] Creating SSH ke
INFO[0001] Creating Virtua
INFO[0006] Starting Virtua
INFO[0007] Waiting for VM
INFO[0041] "dev" has been
24. 24
TOOL NR.2
Docker compose
Docker compose
Describe the relation of your components in a
simple YAML file called docker-compose.yml
and docker-compose takes care of starting
them and linking them in order.
1 stash:
2 image: atlassian/stash
3 ports:
4 - "7990:7990"
5 - "7999:7999"
6 volumes:
7 - /root/orchestration/stash-data:/
8 links:
9 - db
10 user: root
11 privileged: true
12 db:
13 image: postgres
14 environment:
15 POSTGRES_PASSWORD: somepassword
25. • Provision a machine on a PaaS
• Pull PostgreSQL and a Java
app from the Registry
• Use Compose to start the app
• Tear down the machine
Docker compose DEMO
$ docker-compose up -d
26. • “docker-machine create” to provision the host
• Edit “docker-compose.yml” to describe our app
• “docker-compose up -d” to start our application
• “docker-machine rm compose-demo“ to
remove it
Recap of what you saw
$ docker-compose up -d
27. 28
TOOL NR.3
Docker swarm
Deploy images and run containers on a full
clusters as if you’re handling a single machine
Docker swarm
$ docker pull swarm
$ docker run --rm swarm create
6856663cdefdec325839a4b7e1de38e8
29. • Strategies
• Spread
• Binpack
• Random
• Filters
• Constraint
• Affinity
• Port
• Dependency
• Health
Swarm comes with strategies and filters
$ docker run -e
constraint:instance==database --name db
30. • Provision a Docker swarm
• Made up of three hosts
• Master node
• Node with 2gb of RAM
• simple Node
• Use labels to deploy to nodes
• Run Java app and PostgreSQL
on different nodes
The plan for the Swarm DEMO
$ docker pull swarm
$ docker run --rm swarm create
6856663cdefdec325839a4b7e1de38e8
32. @durdn
After Step 2
demo-master
node-1 node-2
label: java
discovery service
Current Architecture
scheduler
RAM: 2GB
label: database
RAM: 512MB
PostgreSQL
33. @durdn
After Step 3
demo-master
node-1 node-2
label: java
discovery service
Current Architecture
scheduler
RAM: 2GB
label: database
RAM: 512MB
PostgreSQLJava App
34. • We created a 3-node cluster with
“docker-machine”
• We tagged the nodes with labels
• We started our components using
label constraints and not machine
names
Recap of Swarm DEMO
$ docker pull swarm
$ docker run --rm swarm create
6856663cdefdec325839a4b7e1de38e8
35. 39
COROLLARY
Docker Java Images Are Big
The default Java image is
800+MB ?!
$ docker pull java
REPOSITORY IMAGE ID VIRTUAL SIZE
java 5282faca75e8 817.6 MB
36. • Alpine Linux provides a minimal
container image of 5MB
• It includes BusyBox and a
package manager
• OpenJDK 7 is already on it…
• Resulting in a 123MB Java image
Start with a smaller base image
FROM alpine:3.2
RUN apk --update add openjdk7-jre
CMD ["/usr/bin/java", "-version"]
37. For Oracle Java 8 you have to roll it your own
http://bit.do/minimal-java
38. I hope you are hyped as I am
for all this coolness, come
talk to me afterwards!