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.
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
Static website Web frontend User DB Queue Analytics DB Background workers API endpoint Development VM QA server Public Cloud Disaster recovery Contributor’s laptop Production Servers Production Cluster Customer Data Center Do services and apps interact appropriately? Can I migrate smoothly and quickly?
Static website Web frontend User DB Queue Analytics DB Background workers API endpoint Development VM QA server Public Cloud Disaster recovery Contributor’s laptop Production Servers Production Cluster Customer Data Center
2- Processes run in a contained environment (containers) ● 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!
● Processes run by Docker share the host Kernel ● No device emulation ● No boot sequence ● Architectures and platforms between Host and containers must match
● 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 a container ● Physical, virtual, cloud...
Ensure the environment your process runs in is the same in dev, test and prod Bring your environment along with your process. Sandboxes everywhere! You'll love that!
# Nginx # # VERSION 0.0.1 FROM ubuntu 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 openssh-server
Docker container B Docker container B Docker container B Docker container B Docker container B Docker container A 3000 3000 3000 3000 3000 5000 5001 5002 5003 5004 3000
2. Create a Rails server image: murielsalvan/server ● 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
4. Create a new image for the Ruby proxy: murielsalvan/proxy ● 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
Without Docker With Docker 0 5 10 15 20 25 30 35 40 45 50 Elapsed time (s) on Fibonacci computation Launch time Execution time Sponsored by the WTF effect!
RSS VSZ 0 20000 40000 60000 80000 100000 120000 140000 160000 180000 Memory consumption per container (kB) Rails Linux container The Linux container memory is always the same whatever the process in the container: 1,5MB RSS and 32MB VSZ