best practices in - scale · best practices in development and deployment, with docker and...
TRANSCRIPT
![Page 1: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/1.jpg)
![Page 2: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/2.jpg)
Best practices indevelopment and deployment,
with Docker and Containers
February 2014—Docker 0.8.1
![Page 3: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/3.jpg)
@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!
![Page 4: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/4.jpg)
Outline
● Why should I care?● The container metaphor● Very quick demo● Working with Docker● Building images● Docker future
![Page 5: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/5.jpg)
Outline
● Why should I care?● The container metaphor● Very quick demo● Working with Docker● Building images● Docker future
![Page 6: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/6.jpg)
Deploy everything
● webapps● backends● SQL, NoSQL● big data● message queues● … and more
![Page 7: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/7.jpg)
Deploy almost everywhere
![Page 8: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/8.jpg)
Deploy almost everywhere
YUP
![Page 9: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/9.jpg)
Deploy almost everywhere
SOONYUP
![Page 10: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/10.jpg)
Deploy almost everywhere
SOON SOONYUP
![Page 11: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/11.jpg)
Deploy almost everywhere
SOON SOONYUP
![Page 12: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/12.jpg)
Deploy almost everywhere
SOON SOON CLIYUP
![Page 13: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/13.jpg)
Deploy almost everywhere
SOON SOON CLIYUP
![Page 14: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/14.jpg)
Deploy almost everywhere
SOON SOON CLI Yeah,right...YUP
![Page 15: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/15.jpg)
Deploy almost everywhere
SOON SOON CLIYUP
![Page 16: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/16.jpg)
Deploy almost everywhere
● Linux servers● VMs or bare metal● Any distro● Kernel 3.8 (or RHEL 2.6.32)
![Page 17: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/17.jpg)
Deploy reliably & consistently
![Page 18: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/18.jpg)
![Page 19: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/19.jpg)
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
![Page 20: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/20.jpg)
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
![Page 21: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/21.jpg)
The performance!It's over 9000!
![Page 22: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/22.jpg)
Outline
● Why should I care?● The container metaphor● Very quick demo● Working with Docker● Building images● Docker future
![Page 23: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/23.jpg)
… Container ?
![Page 24: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/24.jpg)
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 »
![Page 25: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/25.jpg)
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 »
![Page 26: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/26.jpg)
How does it work?Isolation with namespaces
● pid● mnt● net● uts● ipc● user
![Page 27: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/27.jpg)
pid namespace
jpetazzo@tarrasque:~$ ps aux | wc -l212
jpetazzo@tarrasque:~$ sudo docker run -t -i ubuntu bashroot@ea319b8ac416:/# ps auxUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.0 18044 1956 ? S 02:54 0:00 bashroot 16 0.0 0.0 15276 1136 ? R+ 02:55 0:00 ps aux
(That's 2 processes)
![Page 28: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/28.jpg)
mnt namespace
jpetazzo@tarrasque:~$ wc -l /proc/mounts
32 /proc/mounts
root@ea319b8ac416:/# wc -l /proc/mounts
10 /proc/mounts
![Page 29: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/29.jpg)
net namespace
root@ea319b8ac416:/# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever
22: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 2a:d1:4b:7e:bf:b5 brd ff:ff:ff:ff:ff:ff inet 10.1.1.3/24 brd 10.1.1.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::28d1:4bff:fe7e:bfb5/64 scope link valid_lft forever preferred_lft forever
![Page 30: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/30.jpg)
uts namespace
jpetazzo@tarrasque:~$ hostnametarrasque
root@ea319b8ac416:/# hostnameea319b8ac416
![Page 31: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/31.jpg)
ipc namespace
jpetazzo@tarrasque:~$ ipcs------ Shared Memory Segments --------key shmid owner perms bytes nattch status0x00000000 3178496 jpetazzo 600 393216 2 dest 0x00000000 557057 jpetazzo 777 2778672 0 0x00000000 3211266 jpetazzo 600 393216 2 dest
root@ea319b8ac416:/# ipcs------ Shared Memory Segments --------key shmid owner perms bytes nattch status------ Semaphore Arrays --------key semid owner perms nsems ------ Message Queues --------key msqid owner perms used-bytes messages
![Page 32: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/32.jpg)
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 toUID 12000→13999 in host; etc.
● what will happen with copy-on-write?– double translation at VFS?
– single root UID on read-only FS?
![Page 33: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/33.jpg)
How does it work?Isolation with cgroups
● memory● cpu● blkio● devices
![Page 34: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/34.jpg)
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
![Page 35: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/35.jpg)
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
![Page 36: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/36.jpg)
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.
![Page 37: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/37.jpg)
devices cgroups
● controls read/write/mknod permissions● typically:
– allow: /dev/{tty,zero,random,null}...
– deny: everything else
– maybe: /dev/net/tun, /dev/fuse, /dev/kvm, /dev/dri...
● fine-grained control for GPU, virtualization, etc.
![Page 38: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/38.jpg)
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
![Page 39: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/39.jpg)
Storage:many options!
Union Filesystems
Snapshotting Filesystems
Copy-on-writeblock devices
Provisioning SuperfastSupercheap
FastCheap
FastCheap
Changingsmall files
SuperfastSupercheap
FastCheap
FastCostly
Changinglarge files
Slow (first time)Inefficient (copy-up!)
FastCheap
FastCheap
Diffing Superfast Superfast Slow
Memory usage Efficient Efficient Inefficient(at high densities)
Drawbacks Random quirksAUFS not mainline!AUFS more quirks
ZFS not mainlineBTRFS not as nice
Higher disk usageGreat performance (except diffing)
Bottom line Ideal for PAAS and high density things
This is the Future (probably)
Dodge Ram 3500
![Page 40: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/40.jpg)
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
![Page 41: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/41.jpg)
Alright, I get this.Containers = nimble VMs.
![Page 42: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/42.jpg)
![Page 43: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/43.jpg)
The container metaphor
![Page 44: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/44.jpg)
Problem: shipping goods
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
![Page 45: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/45.jpg)
Solution:the intermodal shipping container
![Page 46: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/46.jpg)
Solved!
![Page 47: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/47.jpg)
Problem: shipping code
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ?
![Page 48: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/48.jpg)
Solution:the Linux container
![Page 49: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/49.jpg)
Solved!
![Page 50: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/50.jpg)
Separation of concerns:Dave the Developer
● inside my container:– my code
– my libraries
– my package manager
– my app
– my data
![Page 51: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/51.jpg)
Separation of concerns:Oscar the Ops guy
● outside the container:– logging
– remote access
– network configuration
– monitoring
![Page 52: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/52.jpg)
Separation of concerns:what it doesn't mean
« I don't have to care »≠
« I don't care »
![Page 53: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/53.jpg)
![Page 54: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/54.jpg)
Outline
● Why should I care?● The container metaphor● Very quick demo● Working with Docker● Building images● Docker future
![Page 55: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/55.jpg)
![Page 56: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/56.jpg)
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
![Page 57: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/57.jpg)
What this really means…
● instead of writing « very small shell scripts » tomanage 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!)
![Page 58: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/58.jpg)
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...)
![Page 59: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/59.jpg)
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!
![Page 60: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/60.jpg)
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
![Page 61: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/61.jpg)
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
![Page 62: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/62.jpg)
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
![Page 63: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/63.jpg)
Outline
● Why should I care?● The container metaphor● Very quick demo● Working with Docker● Building images● Docker future
![Page 64: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/64.jpg)
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)
![Page 65: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/65.jpg)
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
![Page 66: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/66.jpg)
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!
![Page 67: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/67.jpg)
Outline
● Why should I care?● The container metaphor● Very quick demo● Working with Docker● Building images● Docker future
![Page 68: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/68.jpg)
Authoring imageswith run/commit
![Page 69: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/69.jpg)
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>
![Page 70: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/70.jpg)
Authoring imageswith 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
![Page 71: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/71.jpg)
Authoring imageswith a Dockerfile
![Page 72: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/72.jpg)
FROM ubuntu
RUN apt-get -y updateRUN 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 = 8101\nbind_address = 0.0.0.0" > /usr/local/etc/couchdb/local.d/docker.ini
EXPOSE 8101CMD ["/usr/local/bin/couchdb"]
docker build -t jpetazzo/couchdb .
![Page 73: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/73.jpg)
Authoring imageswith a Dockerfile
● Minimal learning curve● Rebuilds are easy● Caching system makes rebuilds faster● Single file to define the whole environment!
![Page 74: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/74.jpg)
Do you evenChef?
Puppet?Ansible?
Salt?
![Page 75: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/75.jpg)
Docker and Puppet
![Page 76: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/76.jpg)
![Page 77: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/77.jpg)
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 ☺
![Page 78: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/78.jpg)
Outline
● Why should I care?● The container metaphor● Very quick demo● Working with Docker● Building images● Docker future
![Page 79: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/79.jpg)
Coming Soon
● Network acceleration● Container-specific metrics● Consolidated logging● Plugins (compute backends...)● Orchestration hooks
Those things are already possible,but will soon be part of the core.
![Page 80: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/80.jpg)
Docker 1.0
● Multi-arch, multi-OS● Stable control API● Stable plugin API ● Resiliency● Signature● Clustering
![Page 81: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/81.jpg)
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
![Page 82: Best practices in - SCALE · Best practices in development and deployment, with Docker and Containers February 2014—Docker 0.8.1. @jpetazzo ... pid mnt net uts](https://reader031.vdocuments.site/reader031/viewer/2022022512/5ae3cfb67f8b9a495c8db413/html5/thumbnails/82.jpg)
Thank you! Questions?
http://docker.io/
http://docker.com/
@docker
@jpetazzo