Thiago Rondon, thiago@b-datum.com
Technical meeting b-datum

Monday, December 2, 13
VMs vs Containers
VM

App A App A’ App B

Guest
OS

Guest
OS

Guest
OS

Hypervisor (Type 2)

container

docker

Bin/libs Bin/libs Bin/libs

App App App App
A
A’
B
B’
Bin/libs

Host OS
SERVER

Monday, December 2, 13

Host OS
SERVER

Bin/libs
Containers
App A

App A’

Bin/libs
Original App
No OS to take
up space, resources,
or require restart.

Monday, December 2, 13

Copy of App

Modified App

No OS. Can share
/bin/libs

Union file system allows
us to only save the diffs.
Between container A
and container A’
LXC
“chroot() on steroids”

• LXC (LinuX Containers) let you run a

Linux system within another Linux system.

• a container is a group of processes on a
Linux box, put together in an isolated
environment.

• Inside the box, it look like a VM.
• Outside the box, it looks like a normal
processes.

Monday, December 2, 13
why LXC ?
• Speed - Fast boots, create VM, deploy tasks
• small footprint
• Virtualization - Own [net interface,fs]
• Isolation security and resources.
Monday, December 2, 13
AUFS
• Another Union File System
• Copy-on-write at the FS layer.

Monday, December 2, 13
Cgroup
• ulimit for groups of processes.
• limit, account and isolate resources.
• not perfect for limit I/O.

Monday, December 2, 13
Good example ?
• Do everything you do in VM, but fast!
• How many VMs do you need ?
• Continuous integration !!

Monday, December 2, 13
docker is user-friendly
interface to LXC.

Monday, December 2, 13
docker did all the
following...
•
•
•
•
•
•
•
•

Monday, December 2, 13

It downloaded the base image from the docker index
it created a new LXC container
It allocated a filesystem for it
Mounted a read-write layer
Allocated a network interface
Setup an IP for it, with network address translation
And then executed a process in there
Captured its output and printed it to you
Let’s rock.
•
•
•
•
•

Monday, December 2, 13

docker	
  search	
  ubuntu
docker	
  pull	
  ubuntu
docker	
  run	
  ubuntu	
  echo	
  “hello	
  b-­‐datum”
docker	
  run	
  ubuntu	
  apt-­‐get	
  install	
  -­‐y	
  memcached
docker	
  run	
  -­‐t	
  -­‐i	
  ubuntu	
  /bin/bash
Dockfile
#	
  just	
  for	
  test
FROM	
  ubuntu
RUN	
  apt-­‐get	
  install	
  -­‐y	
  memcached
MAINTAINER	
  Thiago	
  Rondon,	
  thiago@b-­‐datum.com
ENTRYPOINT	
  [“memcached”]
USER	
  daemon
EXPOSE	
  11211

docker build -t mymemcached - < MyDockFile

Monday, December 2, 13
docker exposes git-like commands for
comminting changes to running
containers.
Changes can be commited.
possible by AUFS.

Monday, December 2, 13
Images
•
•
•
•
•

Monday, December 2, 13

docker	
  ps	
  -­‐l
docker	
  commit	
  xxx	
  mystuff/memcached
docker	
  inspect	
  mystuff/memcached
docker	
  images
docker	
  push	
  mystuff/memcached
images & commits

Monday, December 2, 13
History
• docker history
• docker commit
• docker images -viz | dot -Tpng -o
docker.png

• docker images -tree
Monday, December 2, 13
Credits

• http://docker.io

Monday, December 2, 13

Docker

  • 1.
    Thiago Rondon, thiago@b-datum.com Technicalmeeting b-datum Monday, December 2, 13
  • 2.
    VMs vs Containers VM AppA App A’ App B Guest OS Guest OS Guest OS Hypervisor (Type 2) container docker Bin/libs Bin/libs Bin/libs App App App App A A’ B B’ Bin/libs Host OS SERVER Monday, December 2, 13 Host OS SERVER Bin/libs
  • 3.
    Containers App A App A’ Bin/libs OriginalApp No OS to take up space, resources, or require restart. Monday, December 2, 13 Copy of App Modified App No OS. Can share /bin/libs Union file system allows us to only save the diffs. Between container A and container A’
  • 4.
    LXC “chroot() on steroids” •LXC (LinuX Containers) let you run a Linux system within another Linux system. • a container is a group of processes on a Linux box, put together in an isolated environment. • Inside the box, it look like a VM. • Outside the box, it looks like a normal processes. Monday, December 2, 13
  • 5.
    why LXC ? •Speed - Fast boots, create VM, deploy tasks • small footprint • Virtualization - Own [net interface,fs] • Isolation security and resources. Monday, December 2, 13
  • 6.
    AUFS • Another UnionFile System • Copy-on-write at the FS layer. Monday, December 2, 13
  • 7.
    Cgroup • ulimit forgroups of processes. • limit, account and isolate resources. • not perfect for limit I/O. Monday, December 2, 13
  • 8.
    Good example ? •Do everything you do in VM, but fast! • How many VMs do you need ? • Continuous integration !! Monday, December 2, 13
  • 9.
    docker is user-friendly interfaceto LXC. Monday, December 2, 13
  • 10.
    docker did allthe following... • • • • • • • • Monday, December 2, 13 It downloaded the base image from the docker index it created a new LXC container It allocated a filesystem for it Mounted a read-write layer Allocated a network interface Setup an IP for it, with network address translation And then executed a process in there Captured its output and printed it to you
  • 11.
    Let’s rock. • • • • • Monday, December2, 13 docker  search  ubuntu docker  pull  ubuntu docker  run  ubuntu  echo  “hello  b-­‐datum” docker  run  ubuntu  apt-­‐get  install  -­‐y  memcached docker  run  -­‐t  -­‐i  ubuntu  /bin/bash
  • 12.
    Dockfile #  just  for  test FROM  ubuntu RUN  apt-­‐get  install  -­‐y  memcached MAINTAINER  Thiago  Rondon,  thiago@b-­‐datum.com ENTRYPOINT  [“memcached”] USER  daemon EXPOSE  11211 docker build -t mymemcached - < MyDockFile Monday, December 2, 13
  • 13.
    docker exposes git-likecommands for comminting changes to running containers. Changes can be commited. possible by AUFS. Monday, December 2, 13
  • 14.
    Images • • • • • Monday, December 2,13 docker  ps  -­‐l docker  commit  xxx  mystuff/memcached docker  inspect  mystuff/memcached docker  images docker  push  mystuff/memcached
  • 15.
  • 16.
    History • docker history •docker commit • docker images -viz | dot -Tpng -o docker.png • docker images -tree Monday, December 2, 13
  • 17.