2. 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
3. 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’
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 Union File System
• Copy-on-write at the FS layer.
Monday, December 2, 13
7. Cgroup
• ulimit for groups 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
10. 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
11. 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
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-like commands for
comminting changes to running
containers.
Changes can be commited.
possible by AUFS.
Monday, December 2, 13