Quick overview of Docker and its usage.
Illustrated with a cluster of Rails applications and a Ruby load balancing proxy on top of them.
This presentation was made during the rivierarb meetup in Sophia-Antipolis on 2014 Feb 04th by Muriel Salvan.
Ruby and on Rails
Feb 04th 2014
Who am I?
Founder of X-Aeon Solutions
Open Source advocate
Ruby / Rails expert
Co-founder of RivieraRB
My tech blog
Let's talk about cargo transport
(that's why you came here, right?)
"I want my piano to be delivered
from Nice to London"
"I also want my barrel of wine
delivered from Nice to London."
"Hey! Don't forget my bags of rice
"By train, plane, boat, truck, bus,
mule, or whatever!"
Do I worry about how goods interact
(e.g. coffee beans next to spices)
Can I transport quickly and smoothly
(e.g. from boat to train to truck)
A standard container that is loaded with virtually any
goods, and stays sealed until it reaches final delivery.
…in between, can be loaded and unloaded, stacked,
transported efficiently over long distances, and
transferred from one mode of transport to another
Queue Analytics DB
Disaster recovery Contributor’s laptop
Customer Data Center
Do services and apps
Can I migrate smoothly and
Customer Data Center
So what does Docker bring?
1- File systems images
Structured in layers (storing diffs only)
Layers are reused between images
2- Processes run in a contained
Using images' file systems
(isolated like in chroot)
In a separate process space
(using Linux containers)
With a specific network interface
Can run as root
It's chroot on steroids!
3- A public repository of images
Pull and push images
Build them from Github projects
Be part of a great community!
"Is it a yet-another-virtualization-
Processes run by Docker
share the host Kernel
No device emulation
No boot sequence
Architectures and platforms
between Host and containers
"So where is the portability?"
Containers can be run on any Kernel
(>= 3.8, Linux 64b only for now)
Whatever the Linux distro
If it runs on the Host, it can run from
Physical, virtual, cloud...
It's blazingly fast!!!
A few ms to load the container and run the
Get running clusters on a single host
Awesome to test them!
Ensure the environment your process
runs in is the same in dev, test and
Bring your environment along with your process.
You'll love that!
Deployments become sooo easy
Lightweight virtualization too
"How do we create images?"
Describe commands to be run to create an image
# VERSION 0.0.1
MAINTAINER Guillaume J. Charmes
# make sure the package repository is up to date
RUN echo "deb http://archive.ubuntu.com/ubuntu precise
main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y inotify-tools nginx apache2
docker build .
"And how do we run a process in a
"I want to create a modified image"
"Hey! I want to deploy my image for
the world to see!"
"And now my friend wants to get my
wonderful image to play with!"
Yeah, sure... whatever
"Wasn't that supposed to be a Ruby
Let's simulate a Rails cluster with a
balancing Ruby proxy in front!
5000 5001 5002 5003 5004
1. Create a Ruby image:
From ubuntu base image
Using a Dockerfile
Bonus: Upload it to index.docker.io via Github
# Ruby environment
# VERSION 0.2
MAINTAINER Muriel Salvan
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
ADD http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz /tmp/
RUN cd /tmp && \
tar -xzf ruby-2.1.0.tar.gz && \
cd ruby-2.1.0 && \
./configure && \
make && \
make install && \
cd .. && \
rm -rf ruby-2.1.0 && \
rm -f ruby-2.1.0.tar.gz
2. Create a Rails server image:
From murielsalvan/ruby base image
Using an interactive bash in a container to install and
configure the Rails application
Add a startup command: rails s
Open default port 3000
3. Launch n docker containers from
Map each container port 3000 to host ports 5000+i
4. Create a new image for the Ruby
Based on murielsalvan/ruby
Using an interactive bash to install and use em-proxy,
targetting servers on ports 5000+i
Add a startup command: ruby -w balancing.rb
Open port 3000
5. Launch 1 docker container from
Map its guest port 3000 to host port 3000
6. Target localhost:3000
Without Docker With Docker
Elapsed time (s) on Fibonacci computation
Sponsored by the
Memory consumption per container (kB)
The Linux container memory is always the same whatever the process in the container:
1,5MB RSS and 32MB VSZ
Index of Docker images
That's all, folks!
Thanks for attending!