Docker is an Open Source engine to build, run, and manage containers. We'll explain what are Linux Containers, what powers them (under the hood), and what extra value Docker brings to the table. Then we'll see what the typical Docker workflow looks like from a developer point of view. We'll also give an Ops perspective, including deployment options. If you already saw a "Docker 101", consider this presentation as the February 2014 update! :-)
Report
Share
Report
Share
1 of 82
Download to read offline
More Related Content
Docker and Containers for Development and Deployment — SCALE12X
3. @jpetazzo
●
Wrote dotCloud PAAS deployment tools
–EC2,
●
LXC, Puppet, Python, Shell, ØMQ...
Docker contributor
–Docker-in-Docker,
VPN-in-Docker,
router-in-Docker... CONTAINERIZE ALL THE THINGS!
●
Runs Docker in production
–You
shouldn't do it, but here's how anyway!
4. Outline
●
Why should I care?
●
The container metaphor
●
Very quick demo
●
Working with Docker
●
Building images
●
Docker future
5. Outline
●
Why should I care?
●
The container metaphor
●
Very quick demo
●
Working with Docker
●
Building images
●
Docker future
19. Deploy reliably & consistently
●
If it works locally, it will work on the server
●
With exactly the same behavior
●
Regardless of versions
●
Regardless of distros
●
Regardless of dependencies
20. Deploy efficiently
●
Containers are lightweight
–
–
●
Typical laptop runs 10-100 containers easily
Typical server can run 100-1000 containers
Containers can run at native speeds
–
Lies, damn lies, and other benchmarks:
http://qiita.com/syoyo/items/bea48de8d7c6d8c73435
24. High level approach:
it's a lightweight VM
●
own process space
●
own network interface
●
can run stuff as root
●
can have its own /sbin/init
(different from the host)
« Machine Container »
25. Low level approach:
it's chroot on steroids
●
can also not have its own /sbin/init
●
container = isolated process(es)
●
share kernel with host
●
no device emulation (neither HVM nor PV)
« Application Container »
26. How does it work?
Isolation with namespaces
●
pid
●
mnt
●
net
●
uts
●
ipc
●
user
27. pid namespace
jpetazzo@tarrasque:~$ ps aux | wc -l
212
jpetazzo@tarrasque:~$ sudo docker run -t -i ubuntu bash
root@ea319b8ac416:/# ps aux
USER
root
root
PID %CPU %MEM
1 0.0 0.0
16 0.0 0.0
(That's 2 processes)
VSZ
18044
15276
RSS TTY
1956 ?
1136 ?
STAT START
S
02:54
R+
02:55
TIME COMMAND
0:00 bash
0:00 ps aux
32. user namespace
●
●
●
No demo, but see LXC 1.0 (just released)
UID 0→1999 in container C1 is mapped to
UID 10000→11999 in host;
UID 0→1999 in container C2 is mapped to
UID 12000→13999 in host; etc.
what will happen with copy-on-write?
–
double translation at VFS?
–
single root UID on read-only FS?
33. How does it work?
Isolation with cgroups
●
memory
●
cpu
●
blkio
●
devices
34. memory cgroup
●
keeps track pages used by each group:
–
file (read/write/mmap from block devices; swap)
–
anonymous (stack, heap, anonymous mmap)
–
active (recently accessed)
–
inactive (candidate for eviction)
●
each page is « charged » to a group
●
pages can be shared (e.g. if you use any COW FS)
●
Individual (per-cgroup) limits and out-of-memory killer
35. cpu and cpuset cgroups
●
keep track of user/system CPU time
●
set relative weight per group
●
pin groups to specific CPU(s)
–
Can be used to « reserve » CPUs for some apps
–
This is also relevant for big NUMA systems
36. blkio cgroups
●
keep track IOs for each block device
–
read vs write; sync vs async
●
set relative weights
●
set throttle (limits) for each block device
–
read vs write; bytes/sec vs operations/sec
Note: earlier versions (<3.8) didn't account async correctly.
3.8 is better, but use 3.10 for best results.
37. devices cgroups
●
controls read/write/mknod permissions
●
typically:
–
–
deny: everything else
–
●
allow: /dev/{tty,zero,random,null}...
maybe: /dev/net/tun, /dev/fuse, /dev/kvm, /dev/dri...
fine-grained control for GPU, virtualization, etc.
38. How does it work?
Copy-on-write storage
●
Create a new machine instantly
(Instead of copying its whole filesystem)
●
Storage keeps track of what has changed
●
Since 0.7, Docker has a storage plugin system
40. Compute efficiency:
almost no overhead
●
●
●
●
processes are isolated,
but run straight on the host
CPU performance
= native performance
memory performance
= a few % shaved off for (optional) accounting
network performance
= small overhead; can be reduced to zero
54. Outline
●
Why should I care?
●
The container metaphor
●
Very quick demo
●
Working with Docker
●
Building images
●
Docker future
56. Yes, but...
●
●
●
« I don't need Docker;
I can do all that stuff with LXC tools, rsync,
and some scripts! »
correct on all accounts;
but it's also true for apt, dpkg, rpm, yum, etc.
the whole point is to commoditize,
i.e. make it ridiculously easy to use
57. What this really means…
●
instead of writing « very small shell scripts » to
manage containers, write them to do the rest:
–
continuous deployment/integration/testing
–
orchestration
●
= use Docker as a building block
●
re-use other people images (yay ecosystem!)
58. Docker-what?
The Big Picture
●
Open Source engine to commoditize LXC
●
using copy-on-write for quick provisioning
●
allowing to create and share images
●
●
standard format for containers
(stack of layers; 1 layer = tarball+metadata)
standard, reproducible way to easily build
trusted images (Dockerfile, Stackbrew...)
59. Docker-what?
History
●
rewrite of dotCloud internal container engine
–
–
●
original version: Python, tied to dotCloud PaaS
released version: Go, legacy-free
remember SCALE11X talk about LXC?
–
Docker was announced one month later!
60. Docker-what?
Under the hood
●
the Docker daemon runs in the background
–
manages containers, images, and builds
–
HTTP API (over UNIX or TCP socket)
–
embedded CLI talking to the API
61. Docker-what?
Take me to your dealer
●
Open Source
–
●
GitHub public repository + issue tracking
https://github.com/dotcloud/docker
Nothing up the sleeve
–
public mailing lists (docker-user, docker-dev)
–
IRC channels (Freenode: #docker #docker-dev)
–
public decision process
62. Docker-what?
The ecosystem
●
Docker Inc. (formerly dotCloud Inc.)
–
–
●
~30 employees, VC-backed
SAAS and support offering around Docker
Docker, the community
–
more than 300 contributors, 1500 forks on GitHub
–
dozens of projects around/on top of Docker
–
x100k trained developers
63. Outline
●
Why should I care?
●
The container metaphor
●
Very quick demo
●
Working with Docker
●
Building images
●
Docker future
64. One-time setup
●
On your servers (Linux)
–
–
Single binary install (Golang FTW!)
–
●
Packages (Ubuntu, Debian, Fedora, Gentoo, Arch...)
Easy provisioning on Rackspace, Digital Ocean, EC2, GCE...
On your dev env (Linux, OS X, Windows)
–
Vagrantfile
–
boot2docker (25 MB VM image)
–
Natively (if you run Linux)
65. The Docker workflow 1/2
●
●
●
Work in dev environment
(local machine or container)
Other services (databases etc.) in containers
(and behave just like the real thing!)
Whenever you want to test « for real »:
–
Build in seconds
–
Run instantly
66. The Docker workflow 2/2
Satisfied with your local build?
●
Push it to a registry (public or private)
●
Run it (automatically!) in CI/CD
●
Run it in production
●
Happiness!
Something goes wrong? Rollback painlessly!
67. Outline
●
Why should I care?
●
The container metaphor
●
Very quick demo
●
Working with Docker
●
Building images
●
Docker future
72. FROM ubuntu
RUN
RUN
RUN
RUN
RUN
apt-get
apt-get
apt-get
apt-get
apt-get
-y update
install -y
install -y
install -y
install -y
g++
erlang-dev erlang-manpages erlang-base-hipe ...
libmozjs185-dev libicu-dev libtool ...
make wget
RUN wget http://.../apache-couchdb-1.3.1.tar.gz | tar -C /tmp -zxfRUN cd /tmp/apache-couchdb-* && ./configure && make install
RUN printf "[httpd]nport = 8101nbind_address = 0.0.0.0" >
/usr/local/etc/couchdb/local.d/docker.ini
EXPOSE 8101
CMD ["/usr/local/bin/couchdb"]
docker build -t jpetazzo/couchdb .
73. Authoring images
with a Dockerfile
●
Minimal learning curve
●
Rebuilds are easy
●
Caching system makes rebuilds faster
●
Single file to define the whole environment!
77. Docker and Puppet
●
Get a Delorean
●
Warm up flux capacitors
●
Time-travel to yesterday
●
Check Brandon Burton's lightning talk
●
Check my talk
— Or —
●
Get the slides, ask questions ☺
78. Outline
●
Why should I care?
●
The container metaphor
●
Very quick demo
●
Working with Docker
●
Building images
●
Docker future
81. Recap
Docker:
●
Is easy to install
●
Will run anything, anywhere
●
Gives you repeatable builds
●
Enables better CI/CD workflows
●
Is backed by a strong community
●
Will change how we build and ship software