This presentation will introduce you to Docker - the new shiny star on the Devops horizon. It will teach you everything you need to know to get started with Docker, why you'd want to use it and which tools to use to get the most out of it. Additionally to showing the basics, it will introduce helpful libraries available for the JVM and how they can be used together with Docker to create secure, scalable and maintainable cloud setups for your applications.
3. The Challenge
Static website
User DB
Redis +
redis-sentinel
Web frontend
Queue Analytics DB
Background workers
API endpoint
nginx 1.7.6 + modsecurity + openssl +
bootstrap 2
postgresql + pgv8 + v8
hadoop + hive + thrift +
OpenJDK
PlayFramework + sass
BatchEE, jRedis, libcurl + ffmpeg + libopencv +
nodejs + phantomjs
Spray / Akka, jredis + postgresql-jdbc, anorm
Development VM
QA server
Public Cloud
Disaster recovery
Contributor’s
laptop
Production Servers
Multiplicity of
Stacks
Multiplicity of
hardware
environments
Production
Cluster
Customer Data Center
Do services and
apps interact
appropriately?
smoothly and
Can I migrate
quickly?
4. The Matrix From Hell
Static website
Web frontend
Background
workers
User DB
Analytics DB
Queue
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Developm
ent VM
QA
Server
Single
Prod
Server
Onsite
Cluster
Public
Cloud
Contribut
or’s
laptop
Customer
Servers
5. Multiplicity of
Goods
Multipilicity of
methods for
transporting/stor
ing
Do I worry about
interact (e.g.
how goods
next to spices)
cofee beans
Can I transport
quickly and
(e.g. from boat to
smoothly
train to truck)
Cargo Transport Pre-1960
7. Multiplicity Multiplicity of methods for of Goods
transporting/storing
Do I worry about how
coffee beans next to
goods interact (e.g.
Solution: Intermodal Shipping Container
spices)
Can I transport quickly
(e.g. from boat to train
and smoothly
to truck)
…in between, can be
loaded and unloaded,
stacked, transported
efficiently over long
distances, and transferred
from one mode of
transport to another
A standard container
that is loaded with
virtually any goods, and
stays sealed until it
reaches final delivery.
8. Docker is a shipping container system for code
Static website User DB Web frontend Queue Analytics DB
Develop
ment VM
…that can be manipulated
using standard operations
and run consistently on
virtually any hardware
platform
QA server Public Cloud Contributor’
s laptop
Multiplicity of
Stacks
Multiplicity of
hardware
environments
Production
Cluster
Customer
Data Center
Do services and
apps interact
appropriately?
smoothly and
Can I migrate
quickly
An engine that enables
any payload to be
encapsulated as a
lightweight, portable,
self-sufficient
container…
9. Docker eliminates the matrix from Hell
Static website
Web frontend
Background
workers
User DB
Analytics DB
Queue
Develop
ment VM
QA
Server
Single
Prod
Server
Onsite
Cluster
Public
Cloud
Contribut
or’s
laptop
Custome
r Servers
10. Containers vs. VMs
App
A
Bins
/
Libs
Bins
/
Libs
Bins
/
Libs
Hypervisor (Type 2)
Host OS
Server
Gu
est
OS
App
A’
Gu
est
OS
App
B
Gu
est
OS
App
A
Docker
Host OS
Server
App A
Bins/Libs
Bins/Libs
App
B
App B
App
B
App B
VM
Container
Containers are isolated,
but share OS and, where
appropriate, bins/libraries
Gu
est
OS
Gu
est
OS
…result is significantly
faster deployment, much
less overhead, easier
migration, faster restart
11. Docker – Union File System
● aUFS – another UFS
● GIT for file systems
● Layering
● Copy on Write FS
● Can handle millions of
branches
● Docker-Limitation (June
2014)
● 127 Levels (w/o kernel mod)
2014-10-14 Dominik Dorn – docker.io @ JDD14
12. Docker – installation
● On MacOS X 10.6 or newer
2014-10-14 Dominik Dorn – docker.io @ JDD14
13. Docker – installation
● On Ubuntu / Debian
wget -qO- https://get.docker.io/ | sh
# does basically this
sudo apt-key adv --keyserver
hkp://keyserver.ubuntu.com:80 --recv-keys
36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo sh -c "echo deb https://get.docker.io/ubuntu
docker main
> /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install lxc-docker
2014-10-14 Dominik Dorn – docker.io @ JDD14
14. Docker – installation
● If you would like to use Docker as a non-root user, you
should now consider adding your user to the "docker"
group with something like:
sudo usermod -aG docker domdorn
● domdorn@camelion ~ % docker –version
Docker version 1.0.0, build 63fe64c
● Use the install script, ubuntu/debian have old versions
of docker in their Repos!
2014-10-14 Dominik Dorn – docker.io @ JDD14
21. Docker – linking containers
● docker run --link=jddhttp:httpserver -i -t ubuntu ping -c 4 httpserver
PING httpserver (172.17.0.25) 56(84) bytes of data.
64 bytes from httpserver (172.17.0.25): icmp_seq=1 ttl=64 time=0.125 ms
64 bytes from httpserver (172.17.0.25): icmp_seq=2 ttl=64 time=0.065 ms
64 bytes from httpserver (172.17.0.25): icmp_seq=3 ttl=64 time=0.069 ms
64 bytes from httpserver (172.17.0.25): icmp_seq=4 ttl=64 time=0.081 ms
--- httpserver ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.065/0.085/0.125/0.023 ms
2014-10-14 Dominik Dorn – docker.io @ JDD14
22. Docker - Dockerfile
● Recipe to create Docker Containers
● Commands
● ADD – copies files from the file system into the docker container
● RUN – runs a command to build the image (e.g. apt-get install wget)
● CMD – runs a command when the container gets instantiated ( e.g. apt-get update )
● ENTRYPOINT – default command to run when starting a container (e.g. /usr/sbin/nginx )
● ENV – set environment variables
● EXPOSE – make a port available for incoming connections
● FROM – base docker image, e.g. domdorn/nginx or “ubuntu”
● MAINTAINER – name of the maintainer
● USER – execute the entrypoint under a specific UID
● VOLUME – defines directories that get exposed as volumes
● WORKDIR – sets the workdir for the entrypoint
2014-10-14 Dominik Dorn – docker.io @ JDD14
23. Fig
● http://orchardup.github.io/fig/index.html
● Define your app's environment with Docker so it
can be reproduced anywhere
Dockerfile:
FROM orchardup/python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
2014-10-14 Dominik Dorn – docker.io @ JDD14
24. Fig
● Define the services that make up your app so they can be run
together in an isolated environment:
fig.yml:
web:
build: .
command: python app.py
links:
- db
ports:
- "8000:8000"
db:
image: orchardup/postgresql
2014-10-14 Dominik Dorn – docker.io @ JDD14
25. Fig
● Then type fig up, and Fig will start and run your
entire app:
2014-10-14 Dominik Dorn – docker.io @ JDD14
33. CoreOS
● Minimal & optimized OS to run Docker
containers
● https://coreos.com/
● “Linux for Massive Server Deployments
CoreOS enables warehouse-scale computing
on top of a minimal, modern operating system.”
2014-10-14 Dominik Dorn – docker.io @ JDD14