Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Docker Introduction
Creating “batteries included” deployments
Contents
• Introduction to Docker, Containers, and the Matrix from Hell
• The Challenge, the Matrix From Hell
• Why Developers Care
• Technical Explanation
• Docker Compose
• Docker Machine
• Docker Swarm
• Learn More
Static website
Web frontend
User DB Queue
Analytics DB
Background workers API endpoint
nginx 1.5 + modsecurity +
openssl + bootstrap 2
postgresql + pgv8 + v8
hadoop + hive + thrift + OpenJDK
Ruby + Rails + sass + Unicorn
Redis + redis-sentinel
Python 3.0 + celery + pyredis + libcurl
+ ffmpeg + libopencv + nodejs +
phantomjs
Python 2.7 + Flask + pyredis + celery +
psycopg + postgresql-client
DevelopmentVM
QA server
Public Cloud
Disaster recovery
Contributor’s laptopProduction Servers
The Challenge
Production Cluster
Customer Data Center
The Matrix From Hell
Static website ? ? ? ? ? ? ?
Web frontend ? ? ? ? ? ? ?
Background workers ? ? ? ? ? ? ?
User DB ? ? ? ? ? ? ?
Analytics DB ? ? ? ? ? ? ?
Queue ? ? ? ? ? ? ?
DevVM QA Server
Single Prod
Server
Onsite
Cluster
Public
Cloud
Contributor
laptop
Customer
Servers
Cargo Transport Pre-1960
Multiplicty of Goods
Can I transport quickly and smoothly from boat to train to truck?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Also a matrix from hell
Solution: Intermodal Shipping Container
…in between, can be loaded and
unloaded, stacked, transported
efficiently over long distances, and
transferred from one mode of
transport to another
A standard container that is
loaded with virtually any goods,
and stays sealed until it reaches
final delivery.
Static website Web frontendUser DB Queue Analytics DB
DevelopmentVM QA server Public Cloud Contributor’s laptop
Docker is a shipping container system for code
Production
Cluster
Customer
Data Center
…that can be manipulated using
standard operations and run
consistently on virtually any hardware
platform
An engine that enables any
payload to be encapsulated as a
lightweight, portable, self-
sufficient container…
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Development
VM
QA Server
Single Prod
Server
Onsite
Cluster
Public Cloud
Contributor’s
laptop
Customer
Servers
Docker eliminates the matrix from Hell
I am at customer and am
having trouble running our web
application
Is there any messages in the log
file?
Nothing, It’s only a few KB in
size. I will send it to you.
Wierd, but Tomcat is up?
I get a 404 when accessing it.
Postgres doesn’t have any tables
yet.
Sounds like Tomcat didn’t
properly deploy the app.
2 Hours of Additional
Troubleshooting
I noticed that tomcat is picking
up an old version of java 7
We require JDK 8
18
Why Developers Care?
Build once…finally run anywhere
• A clean, safe, hygienic and portable runtime environment for your app.
• No worries about missing dependencies, packages and other pain points
during subsequent deployments
• Run each app in its own isolated container, so you can run various
versions of libraries and other dependencies for each app without worrying
• Automate testing, integration, packaging..anything you can script
• Reduce/eliminate concerns about compatibly on different platforms, either
your own or your customers.
• Cheap, zero-penalty containers to deploy services? A VM without the
overhead of a VM? Instant replay and reset of image snapshots? Thats
the power fo Docker.
Why DevOps Cares?
Configure Once…Run Anything
• Make the entire lifecycle more efficient, consistent, and repeatable
• Increase the quality of code produced by developers.
• Eliminate inconsistencies between development, test, production, and
customer environments.
• Support segregation of duties.
• Significantly improve the speed and reliability of continuous
deployment and integration systems.
• Because the containers are so lightweight, address significant
performance, costs, deployment, and portability issues normally
associated with VMs.
Why it works—separation of concerns
Dan the Developer
• Worries about whats “inside”
the container
• His code
• His Libraries
• His Package Manager
• His Apps
• His Data
Oscar the Ops Guy
• Worries about what’s “outside”
the container
• Logging
• Remote Access
• Monitoring
• Network Config
• All Containers, start, stop,
copy, attach, migrate, etc. the
same way
Why it Works?
• Run everywhere
• Regardless of kernel version
• Regardless of host distort
• Physical or virtual, cloud or not
• Run anything
• If it can run on the host, it can run in the container
• i.e. if it can run on a linux kernel, it can run.
• High Level - Its a lightweight VM
• Own process space
• Own network interface
• Can run stuff as root
• Can have its own /sbin/init (different from host)
Why are Docker containers lightweight?
Bins/
Libs
App
A
Original App
(No OS to take
up space, resources,
or require restart)
AppΔ
App
A
Bins/
Libs
App
A’
Bins/
Libs
Modified
App
Copy on write capabilities
allow
us to only save the diffs
Between container A and
container
A’VMs
Every app, every copy of an
app, and every slight modification
of the app requires a new virtual server
App
A
Guest
OS
Bins/
Libs
Copy of
App
No OS. Can
Share bins/libs
App
A
Guest
OS
Guest
OS
VMs Containers
What are the basics of the Docker system?
Source Code
Repository
Dockerfile
For
A
Docker Engine
Docker
Container
Image
Registry
Build
Docker
Host 2 OS (Linux)
ContainerA
ContainerB
ContainerC
ContainerA
Push
Search
Pull
Run
Host 1 OS (Linux)
Changes and Updates
Bins/
Libs
App
A
Base
Container
Image
Base
Container
Image
AppΔ
Libs
Container
Mod A’’
Container
Mod A’
Docker
Container
Image
Registry
Docker Engine
Bins/
Libs
App
A
Docker Engine
Bins/
Bins/
Libs
App
A’’
Host is now running
A’’
Host running A wants to upgrade to A’’.
Requests update. Gets only diffs
Multiple Linked Containers
• Containers can be linked together
• Sets environment values and host entries so containers
can speak to each other over a local network.
docker pull redis:latest
docker build -t web .
docker run -d --name=db redis:latest redis-server --appendonly yes
docker run -d --name=web --link:db:db -p 5000:5000 -v `pwd`:/code python
app.py
This is still too hard, typing
commands with lots of
arguments takes too long.
Docker Compose
• Multi Container Applications are a Hassle
• Build an Image from Dockerfiles
• Pull images from Docker Hub or a private registry
• Configure, start and Stop containers
docker pull redis:latest
docker build -t web .
docker run -d --name=db redis:latest redis-server --appendonly yes
docker run -d --name=web --link:db:db -p 5000:5000 -v `pwd`:/code python
app.py
Docker Compose
• Docker Compose gets your multi container app running
in one command
docker-compose up
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
redis:
image: redis
Scaling with Docker
Compose
docker-compose scale worker=2
spark
worker
spark master
spark
worker
Scaling with Docker
Compose
docker-compose scale worker=4
spark
worker
spark master
spark
worker
spark
worker
spark
worker
Docker Machine
• Single Binary to create a remote Docker host and setup
the TLS communication with your local docker client
• Automates TLS setup for accessing remote docker
daemon
• Manage multiple machines in different clouds at the
same time
Cloud Ready Deployment
• Docker Machine includes drivers for
• Virtual Box
• VM Ware
• Amazon EC2
• Google Compute
• Digital Ocean
• Many More…
Creating a local Docker Host
$:docker-machine create --driver virtualbox --virtualbox-memory "8000" dev
$:docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
dev virtualbox Running tcp://192.168.99.100:2376
dockerbig * amazonec2 Running tcp://10.0.1.10:2376
$:docker-machine env dev
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/jellin/.docker/machine/machines/dev"
export DOCKER_MACHINE_NAME=“dev"
# Run this command to configure your shell:
# eval "$(docker-machine env dev)"
Docker Swarm
• Native Clustering for Docker hosts
• Dynamically spread container load among multiple
hosts.
• multiple strategies available for ranking node utilization
and availability
• Can integrate with docker machine and api’s such as
Dokku to dynamically allocate additional Docker hosts
as needed.
• Swarm Coordinator run as a container

More Related Content

Docker Introduction

  • 2. Contents • Introduction to Docker, Containers, and the Matrix from Hell • The Challenge, the Matrix From Hell • Why Developers Care • Technical Explanation • Docker Compose • Docker Machine • Docker Swarm • Learn More
  • 3. Static website Web frontend User DB Queue Analytics DB Background workers API endpoint nginx 1.5 + modsecurity + openssl + bootstrap 2 postgresql + pgv8 + v8 hadoop + hive + thrift + OpenJDK Ruby + Rails + sass + Unicorn Redis + redis-sentinel Python 3.0 + celery + pyredis + libcurl + ffmpeg + libopencv + nodejs + phantomjs Python 2.7 + Flask + pyredis + celery + psycopg + postgresql-client DevelopmentVM QA server Public Cloud Disaster recovery Contributor’s laptopProduction Servers The Challenge Production Cluster Customer Data Center
  • 4. The Matrix From Hell Static website ? ? ? ? ? ? ? Web frontend ? ? ? ? ? ? ? Background workers ? ? ? ? ? ? ? User DB ? ? ? ? ? ? ? Analytics DB ? ? ? ? ? ? ? Queue ? ? ? ? ? ? ? DevVM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor laptop Customer Servers
  • 5. Cargo Transport Pre-1960 Multiplicty of Goods Can I transport quickly and smoothly from boat to train to truck?
  • 6. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Also a matrix from hell
  • 7. Solution: Intermodal Shipping Container …in between, can be loaded and unloaded, stacked, transported efficiently over long distances, and transferred from one mode of transport to another A standard container that is loaded with virtually any goods, and stays sealed until it reaches final delivery.
  • 8. Static website Web frontendUser DB Queue Analytics DB DevelopmentVM QA server Public Cloud Contributor’s laptop Docker is a shipping container system for code Production Cluster Customer Data Center …that can be manipulated using standard operations and run consistently on virtually any hardware platform An engine that enables any payload to be encapsulated as a lightweight, portable, self- sufficient container…
  • 9. Static website Web frontend Background workers User DB Analytics DB Queue Development VM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor’s laptop Customer Servers Docker eliminates the matrix from Hell
  • 10. I am at customer and am having trouble running our web application
  • 11. Is there any messages in the log file?
  • 12. Nothing, It’s only a few KB in size. I will send it to you.
  • 14. I get a 404 when accessing it. Postgres doesn’t have any tables yet.
  • 15. Sounds like Tomcat didn’t properly deploy the app.
  • 16. 2 Hours of Additional Troubleshooting
  • 17. I noticed that tomcat is picking up an old version of java 7
  • 19. Why Developers Care? Build once…finally run anywhere • A clean, safe, hygienic and portable runtime environment for your app. • No worries about missing dependencies, packages and other pain points during subsequent deployments • Run each app in its own isolated container, so you can run various versions of libraries and other dependencies for each app without worrying • Automate testing, integration, packaging..anything you can script • Reduce/eliminate concerns about compatibly on different platforms, either your own or your customers. • Cheap, zero-penalty containers to deploy services? A VM without the overhead of a VM? Instant replay and reset of image snapshots? Thats the power fo Docker.
  • 20. Why DevOps Cares? Configure Once…Run Anything • Make the entire lifecycle more efficient, consistent, and repeatable • Increase the quality of code produced by developers. • Eliminate inconsistencies between development, test, production, and customer environments. • Support segregation of duties. • Significantly improve the speed and reliability of continuous deployment and integration systems. • Because the containers are so lightweight, address significant performance, costs, deployment, and portability issues normally associated with VMs.
  • 21. Why it works—separation of concerns Dan the Developer • Worries about whats “inside” the container • His code • His Libraries • His Package Manager • His Apps • His Data Oscar the Ops Guy • Worries about what’s “outside” the container • Logging • Remote Access • Monitoring • Network Config • All Containers, start, stop, copy, attach, migrate, etc. the same way
  • 22. Why it Works? • Run everywhere • Regardless of kernel version • Regardless of host distort • Physical or virtual, cloud or not • Run anything • If it can run on the host, it can run in the container • i.e. if it can run on a linux kernel, it can run. • High Level - Its a lightweight VM • Own process space • Own network interface • Can run stuff as root • Can have its own /sbin/init (different from host)
  • 23. Why are Docker containers lightweight? Bins/ Libs App A Original App (No OS to take up space, resources, or require restart) AppΔ App A Bins/ Libs App A’ Bins/ Libs Modified App Copy on write capabilities allow us to only save the diffs Between container A and container A’VMs Every app, every copy of an app, and every slight modification of the app requires a new virtual server App A Guest OS Bins/ Libs Copy of App No OS. Can Share bins/libs App A Guest OS Guest OS VMs Containers
  • 24. What are the basics of the Docker system? Source Code Repository Dockerfile For A Docker Engine Docker Container Image Registry Build Docker Host 2 OS (Linux) ContainerA ContainerB ContainerC ContainerA Push Search Pull Run Host 1 OS (Linux)
  • 25. Changes and Updates Bins/ Libs App A Base Container Image Base Container Image AppΔ Libs Container Mod A’’ Container Mod A’ Docker Container Image Registry Docker Engine Bins/ Libs App A Docker Engine Bins/ Bins/ Libs App A’’ Host is now running A’’ Host running A wants to upgrade to A’’. Requests update. Gets only diffs
  • 26. Multiple Linked Containers • Containers can be linked together • Sets environment values and host entries so containers can speak to each other over a local network. docker pull redis:latest docker build -t web . docker run -d --name=db redis:latest redis-server --appendonly yes docker run -d --name=web --link:db:db -p 5000:5000 -v `pwd`:/code python app.py
  • 27. This is still too hard, typing commands with lots of arguments takes too long.
  • 28. Docker Compose • Multi Container Applications are a Hassle • Build an Image from Dockerfiles • Pull images from Docker Hub or a private registry • Configure, start and Stop containers docker pull redis:latest docker build -t web . docker run -d --name=db redis:latest redis-server --appendonly yes docker run -d --name=web --link:db:db -p 5000:5000 -v `pwd`:/code python app.py
  • 29. Docker Compose • Docker Compose gets your multi container app running in one command docker-compose up web: build: . ports: - "5000:5000" volumes: - .:/code links: - redis redis: image: redis
  • 30. Scaling with Docker Compose docker-compose scale worker=2 spark worker spark master spark worker
  • 31. Scaling with Docker Compose docker-compose scale worker=4 spark worker spark master spark worker spark worker spark worker
  • 32. Docker Machine • Single Binary to create a remote Docker host and setup the TLS communication with your local docker client • Automates TLS setup for accessing remote docker daemon • Manage multiple machines in different clouds at the same time
  • 33. Cloud Ready Deployment • Docker Machine includes drivers for • Virtual Box • VM Ware • Amazon EC2 • Google Compute • Digital Ocean • Many More…
  • 34. Creating a local Docker Host $:docker-machine create --driver virtualbox --virtualbox-memory "8000" dev $:docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM dev virtualbox Running tcp://192.168.99.100:2376 dockerbig * amazonec2 Running tcp://10.0.1.10:2376 $:docker-machine env dev export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.100:2376" export DOCKER_CERT_PATH="/Users/jellin/.docker/machine/machines/dev" export DOCKER_MACHINE_NAME=“dev" # Run this command to configure your shell: # eval "$(docker-machine env dev)"
  • 35. Docker Swarm • Native Clustering for Docker hosts • Dynamically spread container load among multiple hosts. • multiple strategies available for ranking node utilization and availability • Can integrate with docker machine and api’s such as Dokku to dynamically allocate additional Docker hosts as needed. • Swarm Coordinator run as a container