Documente Academic
Documente Profesional
Documente Cultură
The DevOps
Challenge
Next-Gen Cloud Computing and DevOps with
Beyond VMs Docker Containers
The How of
Docker
Docker 101
Hamilton Turner
Docker
Examples hamiltont@gmail.com
Docker Limits
Hadoop Demo
Conclusions
March 12, 2014
March 2014 1 / 43
Who am I?
Who Am I? Who am I?
The DevOps • Ph.D. Candidate at Virginia Tech
Challenge
• Defending in Fall 2014
Beyond VMs
The How of
• Member of Magnum Research Group
Docker (http://www.magnum.io/)
Docker 101 • We focus on mobile and cloud applications
Docker
Examples How do I use Docker?
Docker Limits • Stress test 100+ web apps, without installing natively
Hadoop Demo
• Manage computer cluster for research group
Conclusions
• Personal playground for learning new technologies
March 2014 2 / 43
DevOps Challenges: The Matrix From Hell
Conclusions
March 2014 3 / 43
Review of Virtual Machines
Who Am I?
Beyond VMs
executed as a program
The How of • No developer’s local
Docker
system has to be modified
Docker 101
Docker
• The entire VM disk image
Examples
can be shared
Docker Limits
• No more differences
Hadoop Demo
Conclusions
between dev and
production environments!
• This is great! ....Right?
March 2014 4 / 43
Comparison of Docker Containers And VMs
Who Am I?
The DevOps
Challenge
Beyond VMs
The How of
Docker
Docker 101 Credit: quay.io - A Secure Hosting Solution For Private Docker Repositories
Docker
Examples
Docker Container Virtual Machine
Docker Limits
Avg Host Resources Consumed Low High
Hadoop Demo Clean Startup Time seconds minutes/hours
Conclusions Environment (FS) Sharing Small (Union filesystem) Large (Entire Snapshot)
Environment Reproducibility High Moderate (AWS image)
Software Modifications Needed? Perhaps (one process) Unlikely
Attack Surface Untested Small
System Monitoring Use Linux Tools Custom systems
March 2014 5 / 43
The How of Docker
Conclusions
March 2014 6 / 43
The How of Docker, Union Filesystem Version
March 2014 7 / 43
Docker 101: Run Interactive Container
$ su do d o c k e r r u n − i −t ubuntu / b i n / b a s h
Who Am I?
• sudo : Docker has to be run as root!
The DevOps • run : we are running a container
• -i -t : we want a terminal (stdin and stdout), and we
Challenge
Beyond VMs
want to be connected to those so we can interact with
The How of
Docker the continer
Docker 101 • ubuntu : The base image for this container
Docker
Examples
• /bin/bash : Let’s run bash
Docker Limits $ su do d o c k e r r u n − i −t ubuntu / b i n / b a s h
Hadoop Demo r o o t @ 0 3 7 1 1 5 5 9 d 5 7 d : / # cat / etc /* release *
Conclusions DISTRIB ID=Ubuntu
DISTRIB RELEASE =12.04
DISTRIB CODENAME=p r e c i s e
DISTRIB DESCRIPTION=” Ubuntu 1 2 . 0 4 LTS”
r o o t @ 0 3 7 1 1 5 5 9 d 5 7 d : / # exit
March 2014 8 / 43
Docker 101: Run Non-Interactive Container
Docker 101
Odd things:
Docker • There was no ‘hi’
Examples
The DevOps
$ su do d o c k e r r u n −d ubuntu / b i n / b a s h −c ” e c h o h i ”
Challenge d2026870efedf09e29dbea146d399e60493e9dd0ebbf6124347d6
Beyond VMs $ su do d o c k e r l o g s d 2 0 2 6 8 7 0 e f e d f 0 9 e 2 9 d b e a 1 4 6 d 3 9 9 e 6 0 4 9
The How of hi
Docker
March 2014 10 / 43
More on Container IDs
Beyond VMs
filesystem into an image
The How of
• The image can then be used to run
Docker
other containers
Docker 101
$ APP=$ ( su do d o c k e r r u n −d ubuntu / b i n / b a s h −c
Docker
Examples
‘ ‘ e c h o h i > c o n f i g . out ’ ’ )
$ su do d o c k e r commit $APP h a m i l t o n t /myapp
Docker Limits
$ su do d o c k e r r u n − i −t h a m i l t o n t /myapp / b i n / b a s h
Hadoop Demo
r o o t @ 3 a 1 f 0 c 2 8 b 8 2 2 : / # cat config . out
Conclusions hi
March 2014 12 / 43
Sharing An Image For Reuse
The How of
• If docker run does not find the image locally, it will
Docker automatically search known registries
Docker 101
Hadoop Demo • The images subcommand can be used to list local images
Conclusions
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
h a m i l t o n t /myapp latest d100b411c51e 2 m i n u t e s ago 2 0 4 . 4 MB
h a m i l t o n t / myotherapp latest 7 cb2d9010d39 11 d a y s ago 4 1 0 . 6 MB
ubuntu 12.04 9 cd978db300e 5 weeks ago 2 0 4 . 4 MB
ubuntu latest 9 cd978db300e 5 weeks ago 2 0 4 . 4 MB
March 2014 13 / 43
Benefits of Using Union Filesystems For Images
• Hypothetical:
Who Am I? • I run a ubuntu container, make changes, and exit
The DevOps • I commit my changes to an image and run docker push
Challenge
• My colleage wants to docker pull my image
Beyond VMs
• What do they need to download?
The How of
Docker • Answer:
Docker 101 • Just your changes!
Docker • They have probably already downloaded the ubuntu base
Examples
image
Docker Limits
Hadoop Demo
• No inherent need for multi-GB images
Conclusions • Download only files, not arbitrary filesystem junk
• While YMMV,
80% of images are ≤ 50MB, 95% are ≤ 500MB
March 2014 14 / 43
Linking Host/Container Filesystems
March 2014 15 / 43
Exposing Container Network Ports
Hadoop Demo
• -p 8000 caused Docker to find an unused host port and
Conclusions
link it with the container-internal port 8000
• We used the port subcommand to find this public port
• There is nothing listening on port 8000 in the container,
so this is kind of boring
March 2014 16 / 43
Exposing Container Network Ports, Part Two
Docker Limits
Note:
Hadoop Demo • I chose to reuse hamiltont/python-simplehttpserver
Conclusions
• Navigating to http://localhost:49186 will now
connect me to the webserver
• The container knew what command to run! More on this
next...
March 2014 17 / 43
Building Images with Dockerfiles
Docker Limits
Hadoop Demo
Conclusions
March 2014 18 / 43
Locating Community Images
Who Am I?
The DevOps
Challenge
Beyond VMs
• There are hundreds of community-contributed and/or
The How of
Docker official images online at http://index.docker.io
Docker 101
• This is the official registry, you can also host your own
Docker
Examples • You can also use the docker search subcommand to
Docker Limits interact with index.docker.io
Hadoop Demo
$ sudo docker s e a r c h w o r d p r e s s
Conclusions NAME DESCRIPTION STARS TRUSTED
c t l c / wordpress 4 [OK]
j b f i n k / d o c k e r−wor Same a s j b f i n k / w o r d p r e s s , j u s t a t r u s t e d b 2 [OK]
skxskx / wordpress W o r d p r e s s & SSH i n a c o n t a i n e r . 2
eugeneware / docker 1 [OK]
tutum / w o r d p r e s s W o r d p r e s s Docker image − l i s t e n s i n p o r t 80 1 [OK]
j b f i n k / wordpress Wordpress 3.8 1
March 2014 19 / 43
Docker 101 Review: Topics Covered
Conclusions
• Basic concept of Dockerfiles
March 2014 20 / 43
Docker 101: Things We Didn’t Cover
Conclusions
• Limiting container memory and CPU consumption
Docker
Blogging / CMS Wordpress, Ghost
Examples Single-use tool usage Redis CLI, Latex, subuser
Docker Limits
Continuous Integration Jenkins, Drone
Hadoop Demo
Proxy Software Hipache, Nginx/Apache/noje.js
Conclusions
PaaS Cocaine (from Yandex), Deis,
Flynn, Bowery, Dokku
March 2014 22 / 43
Example: Wordpress
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 23 / 43
Example: Redis Commander Web GUI
Who Am I?
The DevOps
Challenge
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 24 / 43
Example: Sandboxed Dev Environment
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 25 / 43
Example: SSH Server
root@7d45b427eca1 : ˜ #
March 2014 26 / 43
Example: Continuous Integration
Who Am I?
Note: I’ve limited the CPU shares allowed
The DevOps
Challenge
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 27 / 43
Example: Quick Web Server
Who Am I?
Note: I’ve mounted my /Programming folder to /www
The DevOps
Challenge
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 28 / 43
Example: Using Redis CLI Without Installing It
Docker 101
• Redis is not installed on the host
Docker
Examples • I can use complex (and stateful!) commands without
Docker Limits modifying the host machine
Hadoop Demo
• I could even pull my dotfiles onto a production machine
Conclusions
• No noticable run delay
March 2014 29 / 43
Example: Preexisting Automation Tools
March 2014 30 / 43
Docker Is Not a Panacea: Considerations
Who Am I?
The DevOps
• No Shared Libraries
Challenge • The price of process isolation
• ADD-only filesystem
Beyond VMs
The How of
Docker • Scenario: Run a huge build and then rm /tmp/*
Docker 101 • Result: All of /tmp will be downloaded, and
Docker then masked with an empty directory
Examples
• Root access required for simple operations!
Docker Limits
• Progress is being made on this front
Hadoop Demo
March 2014 31 / 43
Docker Service Orchestration and Service Discovery
Beyond VMs
within contianers
• volumes from can be used to share these volumnes with
The How of
Docker other containers
Docker 101 • Containers can be linked to share their network
Docker • Fig: Uses simple config to start/link containers
Examples
Conclusions
Fast Fail Results:
• 250 containers launched before “Too many open files”
• <2GB memory used, load of 3 (all sleeping)
March 2014 33 / 43
Recap: Docker and Virtual Machines
March 2014 34 / 43
Docker and Hadoop
Who Am I?
What do I need?
The DevOps • Development Environment
Challenge
• With full source code / docs
Beyond VMs
• Good base image for configuring IDE
The How of
• Production Environment
Ubuntu:12.04
Docker
Hadoop Demo
Conclusions
• Yes, Java
• Ok, so three images: Java, Dev,
Production
March 2014 35 / 43
Developing Oracle Java7 Image
Who Am I?
The DevOps
Challenge
Hadoop Demo
Conclusions
March 2014 36 / 43
Who Am I?
The DevOps
Challenge
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 37 / 43
Developing Hadoop-Dev Image
Who Am I?
The DevOps
Challenge • Build on top of Java7 image
Beyond VMs
• Install build tools
The How of
Docker • Install hadoop build dependencies
Docker 101
• Run build process
Docker
Examples
• Of Note: This image is huge! > 1GB due to all the build
Docker Limits
dependencies downloaded by maven
Hadoop Demo
Conclusions
March 2014 38 / 43
Developing Hadoop Docker
Who Am I?
The DevOps
Challenge
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 39 / 43
Developing Hadoop Image
Conclusions
github.com/hamiltont/hadoop-docker
March 2014 40 / 43
Developing Hadoop Docker
Who Am I?
The DevOps
Challenge
Beyond VMs
The How of
Docker
Docker 101
Docker
Examples
Docker Limits
Hadoop Demo
Conclusions
March 2014 41 / 43
Conclusions: Who and What is Docker
March 2014 42 / 43
Thank You For Your Time
Who Am I?
The DevOps
Challenge
Questions?
Beyond VMs
The How of
Docker
Docker 101 Please feel free to reuse/modify presentation if you wish, just
Docker
Examples
remember to leave my name in there somewhere. It’s online at
Docker Limits https://github.com/hamiltont/intro-to-docker
Hadoop Demo
Conclusions
March 2014 43 / 43