Introduction to Docker
May 2014—Docker 0.11.0XXXXX0.11.1
@jpetazzo
● Wrote dotCloud PAAS deployment tools
– EC2, LXC, Puppet, Python, Shell, ØMQ...
● Docker contributor
– Docker-i...
What?
Why?
Deploy everything
● Webapps
● Backends
● SQL, NoSQL
● Big data
● Message queues
● … and more
Deploy almost everywhere
● Linux servers
● VMs or bare metal
● Any distro
● Kernel 3.8 (or RHEL 2.6.32)
Currently: focus o...
Deploy reliably & consistently
Deploy reliably & consistently
● If it works locally, it will work on the server
● With exactly the same behavior
● Regard...
Deploy efficiently
● Containers are lightweight
– Typical laptop runs 10-100 containers easily
– Typical server can run 10...
The performance!
It's over 9000!
Is there really
no overhead at all?
● Processes are isolated,
but run straight on the host
● CPU performance
= native perf...
… Container ?
High level approach:
it's a lightweight VM
● Own process space
● Own network interface
● Can run stuff as root
● Can have ...
Low level approach:
it's chroot on steroids
● Can also not have its own /sbin/init
● Container = isolated process(es)
● Sh...
How does it work?
Isolation with namespaces
● pid
● mnt
● net
● uts
● ipc
● user
How does it work?
Isolation with cgroups
● memory
● cpu
● blkio
● devices
How does it work?
Copy-on-write storage
● Create a new machine instantly
(Instead of copying its whole filesystem)
● Stora...
Union Filesystems
(AUFS, overlayfs)
Copy-on-write
block devices
Snapshotting
filesystems
Provisioning Superfast
Supercheap...
Alright, I get this.
Containers = nimble VMs.
The container metaphor
Problem: shipping goods
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
Solution:
the intermodal shipping container
Solved!
Problem: shipping code
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
Solution:
the Linux container
Solved!
Separation of concerns:
Dave the Developer
● Inside my container:
– my code
– my libraries
– my package manager
– my app
–...
Separation of concerns:
Oscar the Ops guy
● Outside the container:
– logging
– remote access
– network configuration
– mon...
Docker-what?
The Big Picture
● Open Source engine to commoditize LXC
● Using copy-on-write for quick provisioning
● Allowi...
Docker-what?
History
● Rewrite of dotCloud internal container engine
– original version: Python, tied to dotCloud PaaS
– r...
Docker-what?
Under the hood
● The Docker daemon runs in the background
– manages containers, images, and builds
– HTTP API...
Docker-what?
Take me to your dealer
● Open Source
– GitHub public repository + issue tracking
https://github.com/dotcloud/...
One-time setup
● On your servers (Linux)
– Packages (Ubuntu, Debian, Fedora, Gentoo, Arch...)
– Single binary install (Gol...
The Docker workflow 1/2
● Work in dev environment
(local machine or container)
● Other services (databases etc.) in contai...
The Docker workflow 2/2
Satisfied with your local build?
● Push it to a registry (public or private)
● Run it (automatical...
Authoring images
with run/commit
1) docker run ubuntu bash
2) apt-get install this and that
3) docker commit <containerid> <imagename>
4) docker run <image...
Authoring images
with run/commit
● Pros
– Convenient, nothing to learn
– Can roll back/forward if needed
● Cons
– Manual p...
Authoring images
with a Dockerfile
FROM ubuntu
RUN apt-get -y update
RUN apt-get install -y g++
RUN apt-get install -y erlang-dev erlang-manpages erlang-base...
Authoring images
with a Dockerfile
● Minimal learning curve
● Rebuilds are easy
● Caching system makes rebuilds faster
● S...
Checkpoint
With Docker, I can:
● put my software in containers
● run those containers anywhere
● write recipes to automati...
Half Time
… Questions so far ?
http://docker.io/
http://docker.com/
@docker
@jpetazzo
What's new in 0.10?
● TLS auth for API
● Tons of stability and usability improvements
(devicemapper, hairpin NAT, ptys...)...
What's new in 0.11?
● SELinux support
● --net flag for special network features
(you don't need to use pipework anymore!)
...
Docker 1.0
● ☒ Multi-arch, multi-OS
● ☒ Stable control API
● ☒ Stable plugin API
● ☐ Resiliency
● ☑ Clustering
Do
You
Even
Ship?
Running (some) containers
● SSH to Docker host and manual pull+run
● Fig
https://github.com/orchardup/fig
● Maestro NG
htt...
Running (more) containers
More on this
in a minute.
Identify your containers
● You can name your containers
docker run -d -name www_001 myapp
● Ensures uniqueness
Connect your containers
● Links!
docker run -d -name frontdb mysqlimage
docker run -d -link frontdb:sql nginximage
→ envir...
Connect your containers
across multiple hosts
● Ambassador pattern
host 1 (database)
docker run -d -name frontdb mysqlimag...
db host web host
database container
I'm frontdb!
web container
I want to talk to frontdb!
wiring container
I actually talk...
db host web host
database container
I'm frontdb!
web container
I want to talk to frontdb!
wiring container
I actually talk...
I can't afford Unicorns!
● Service discovery (registry):
Zookeeper / Etcd / Consul
● Traffic routing:
stunnel / haproxy / ...
Running (more) containers
● OpenStack (Nova, Heat)
● OpenShift (geard)
● Other PAAS:
Deis, Cocaine (Yandex), Flynn...
● Do...
Can we do better?
● The « dockermux » design pattern
● Run something that:
– exposes the Docker API
– talks to real Docker...
Thank you! Questions?
http://docker.io/
http://docker.com/
@docker
@jpetazzo
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Upcoming SlideShare
Loading in …5
×

Docker 0.11 at MaxCDN meetup in Los Angeles

5,306 views
5,198 views

Published on

Docker is the Open Source container engine. It lets you author, run, and manage software containers. Escape from dependency hell, and make deployment a breeze! This presentation includes the standard Docker intro (actualized for Docker 0.11) as well as some insights about how to perform orchestration and multi-host container linking.

Published in: Technology
2 Comments
9 Likes
Statistics
Notes
No Downloads
Views
Total views
5,306
On SlideShare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
62
Comments
2
Likes
9
Embeds 0
No embeds

No notes for slide

Docker 0.11 at MaxCDN meetup in Los Angeles

  1. 1. Introduction to Docker May 2014—Docker 0.11.0XXXXX0.11.1
  2. 2. @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!
  3. 3. What?
  4. 4. Why?
  5. 5. Deploy everything ● Webapps ● Backends ● SQL, NoSQL ● Big data ● Message queues ● … and more
  6. 6. Deploy almost everywhere ● Linux servers ● VMs or bare metal ● Any distro ● Kernel 3.8 (or RHEL 2.6.32) Currently: focus on x86_64. (But people reported success on arm.)
  7. 7. Deploy reliably & consistently
  8. 8. 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
  9. 9. 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
  10. 10. The performance! It's over 9000!
  11. 11. Is there really no overhead at all? ● Processes are isolated, but run straight on the host ● CPU performance = native performance ● Memory performance = a few % shaved off for (optional) accounting ● Network and disk I/O performance = small overhead; can be reduced to zero
  12. 12. … Container ?
  13. 13. 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 »
  14. 14. 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 »
  15. 15. How does it work? Isolation with namespaces ● pid ● mnt ● net ● uts ● ipc ● user
  16. 16. How does it work? Isolation with cgroups ● memory ● cpu ● blkio ● devices
  17. 17. 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 ● Multiple storage plugins available (AUFS, device mapper, BTRFS, VFS...)
  18. 18. Union Filesystems (AUFS, overlayfs) Copy-on-write block devices Snapshotting filesystems Provisioning Superfast Supercheap Fast Cheap Fast Cheap Changing small files Superfast Supercheap Fast Costly Fast Cheap Changing large files Slow (first time) Inefficient (copy-up!) Fast Cheap Fast Cheap Diffing Superfast Slow Superfast Memory usage Efficient Inefficient (at high densities) Inefficient (but may improve) Drawbacks Random quirks AUFS not mainline Higher disk usage Great performance (except diffing) ZFS not mainline BTRFS not as nice Bottom line Ideal for PAAS and high density things Dodge Ram 3500 This is the future (Probably!) Storage options
  19. 19. Alright, I get this. Containers = nimble VMs.
  20. 20. The container metaphor
  21. 21. Problem: shipping goods ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  22. 22. Solution: the intermodal shipping container
  23. 23. Solved!
  24. 24. Problem: shipping code ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  25. 25. Solution: the Linux container
  26. 26. Solved!
  27. 27. Separation of concerns: Dave the Developer ● Inside my container: – my code – my libraries – my package manager – my app – my data
  28. 28. Separation of concerns: Oscar the Ops guy ● Outside the container: – logging – remote access – network configuration – monitoring
  29. 29. 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...)
  30. 30. Docker-what? History ● Rewrite of dotCloud internal container engine – original version: Python, tied to dotCloud PaaS – released version: Go, legacy-free
  31. 31. 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
  32. 32. 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 – Docker Governance Advisory Board
  33. 33. One-time setup ● On your servers (Linux) – Packages (Ubuntu, Debian, Fedora, Gentoo, Arch...) – Single binary install (Golang FTW!) – 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)
  34. 34. 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
  35. 35. 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!
  36. 36. Authoring images with run/commit
  37. 37. 1) docker run ubuntu bash 2) apt-get install this and that 3) docker commit <containerid> <imagename> 4) docker run <imagename> bash 5) git clone git://.../mycode 6) pip install -r requirements.txt 7) docker commit <containerid> <imagename> 8) repeat steps 4-7 as necessary 9) docker tag <imagename> <user/image> 10) docker push <user/image>
  38. 38. Authoring images with run/commit ● Pros – Convenient, nothing to learn – Can roll back/forward if needed ● Cons – Manual process – Iterative changes stack up – Full rebuilds are boring, error-prone
  39. 39. Authoring images with a Dockerfile
  40. 40. FROM ubuntu RUN apt-get -y update RUN apt-get install -y g++ RUN apt-get install -y erlang-dev erlang-manpages erlang-base- hipe ... RUN apt-get install -y libmozjs185-dev libicu-dev libtool ... RUN apt-get install -y make wget RUN wget http://.../apache-couchdb-1.3.1.tar.gz | tar -C /tmp -zxf- RUN 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 .
  41. 41. Authoring images with a Dockerfile ● Minimal learning curve ● Rebuilds are easy ● Caching system makes rebuilds faster ● Single file to define the whole environment!
  42. 42. Checkpoint With Docker, I can: ● put my software in containers ● run those containers anywhere ● write recipes to automatically build containers But how do I: ● run containers aplenty? ● manage fleets of container hosts? ● ship to, you know, production?
  43. 43. Half Time … Questions so far ? http://docker.io/ http://docker.com/ @docker @jpetazzo
  44. 44. What's new in 0.10? ● TLS auth for API ● Tons of stability and usability improvements (devicemapper, hairpin NAT, ptys...) ● FreeBSD support (client)
  45. 45. What's new in 0.11? ● SELinux support ● --net flag for special network features (you don't need to use pipework anymore!) ● stability, stability, stability, stability
  46. 46. Docker 1.0 ● ☒ Multi-arch, multi-OS ● ☒ Stable control API ● ☒ Stable plugin API ● ☐ Resiliency ● ☑ Clustering
  47. 47. Do You Even Ship?
  48. 48. Running (some) containers ● SSH to Docker host and manual pull+run ● Fig https://github.com/orchardup/fig ● Maestro NG https://github.com/signalfuse/maestro-ng ● Replace yourself with a simple shell script
  49. 49. Running (more) containers More on this in a minute.
  50. 50. Identify your containers ● You can name your containers docker run -d -name www_001 myapp ● Ensures uniqueness
  51. 51. Connect your containers ● Links! docker run -d -name frontdb mysqlimage docker run -d -link frontdb:sql nginximage → environment vars are injected in web container → twelve-factors FTW!
  52. 52. Connect your containers across multiple hosts ● Ambassador pattern host 1 (database) docker run -d -name frontdb mysqlimage docker run -d -link frontdb:sql wiring host 2 (web tier) docker run -d -name frontdb wiring docker run -d -link frontdb:sql nginximage
  53. 53. db host web host database container I'm frontdb! web container I want to talk to frontdb! wiring container I actually talk to frontdb! wiring container I pretend I'm frontdb! docker link docker link ?
  54. 54. db host web host database container I'm frontdb! web container I want to talk to frontdb! wiring container I actually talk to frontdb! wiring container I pretend I'm frontdb! docker link docker link UNICORNS
  55. 55. I can't afford Unicorns! ● Service discovery (registry): Zookeeper / Etcd / Consul ● Traffic routing: stunnel / haproxy / iptables ● Stay Tuned
  56. 56. Running (more) containers ● OpenStack (Nova, Heat) ● OpenShift (geard) ● Other PAAS: Deis, Cocaine (Yandex), Flynn... ● Docker Executor for Mesos ● Roll your own with the REST API
  57. 57. Can we do better? ● The « dockermux » design pattern ● Run something that: – exposes the Docker API – talks to real Docker hosts – spins up more Docker hosts – takes care of scheduling, plumbing, scaling...
  58. 58. Thank you! Questions? http://docker.io/ http://docker.com/ @docker @jpetazzo

×