COURSE INTRODUCTION
DAY 01• Docker Introduction• Installation of Docker• Working with Containers• Working with Images• Building image with Dockerfiles• OpenStack Integration• OpenStack Introduction• Nova Driver (Docker as Compute
Service)• Glance as Docker image registry
DAY 02• Docker Cluster• Kubernetes Introduction• Docker Networking• Docker Hub• Docker Cases• Docker Source Code• Development Platform With
Docker• Hadoop on Docker
�� 8 n , D rS OcM k8 l
o n O e n gtue S p 8 o
a G P 8yh
[email protected]://github.com/onetownhttp://liangbo.me
Infrastructure 90%
Storage, Network, Virtualization ,Container 40%
Front-end, HTML, CSS, Javascript 60%
Python, C Sharp, Go-lang Development 90%Liang Bo (TRYSTACK.CN���)
Docker For BeginnersDocker is an open platform for developers and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows, Docker enables apps to be quickly assembled from components and
eliminates the friction between development, QA, and production environments. As a result, IT can ship faster and run the same app, unchanged, on laptops, data center VMs, and any cloud.
03 Looking for Something Specific
Develop, Ship and Run any application, anywhere
04 Looking for Help
https://docs.docker.com
02Learning
Docker consists of:The Docker Engine - our lightweight and powerful open source container virtualization technology combined with a work flow for building and containerizing your applications.Docker Hub - our SaaS service for sharing and managing your application stacks.
01Installation
Docker requires a 64-bit installation regardless of your Linux version. Additionally, your kernel must be 3.10 at minimum. The latest 3.10 minor version or a newer maintained version are also acceptable.
The$ChallengeStatic 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
Development VM
QA server
Public Cloud
Disaster recovery
Contributor’s laptopProduction Servers
Mult
iplici
ty of
Stack
sM
ultipl
icity
of ha
rdwa
re
envir
onme
nts
Production Cluster
Customer Data Center
Do services and apps interact appropriately?
Can I migrate smoothly and quickly?
Application$MatrixStatic 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
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Explanation
• High Level—It’s a lightweight VM• Own process space• Own network interface• Can run stuff as root• Can have its own /sbin/init (different from
host)• <<machine container>>
• Low Level—It’s chroot on steroids• Can also not have its own /sbin/init• Container=isolated processes• Share kernel with host• No device emulation (neither HVM nor PV)
from host)• <<application container>>
• Run everywhere• Regardless of kernel version (2.6.32+)• Regardless of host distro• Physical or virtual, cloud or not• Container and host architecture must
match*
• 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
WHY WHAT
Introduction
• Docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self-sufficient container that will run virtually anywhere.
• Based on LXC (Linux Container), easy to use.• Similar to VM as end-user with different features.• Founded in 2013 (dotCloud)• Joined Linux Foundation• Apache 2.0 License• Implemented by Golang
Bins/Libs
AppA
Original App(No OS to takeup space, resources,or require restart)
App Δ
Bins/
AppA
Bins/Libs
AppA’
GuestOS
Bins/Libs
Modified App
Copy on write capabilities allowus to only save the diffsBetween container A and containerA’
VMsEvery app, every copy of anapp, and every slight modificationof the app requires a new virtual server
AppA
GuestOS
Bins/Libs
Copy of AppNo OS. CanShare bins/libs
AppA
GuestOS
GuestOS
VMs Containers
Basic$Docker System
Source Code Repository
DockerfileFor A
Docker Engine
DockerContainer
Image Registry
Build
Docker
Host 2 OS (Linux)
Container A
Container B
Container C
Container A
Push
Search Pull
Run
Host 1 OS (Linux)
Changes$and$Updates
Docker Engine
DockerContainer
Image Registry
Docker Engine
Push
Update
Bins/Libs
AppA
App Δ
Bins/
Base Container
Image
Host is now running A’’
Container Mod A’’
App Δ
Bins/
Bins/Libs
AppA
Bins/
Bins/Libs
AppA’’
Host running A wants to upgrade to A’’. Requests update. Gets only diffs
Container Mod A’
Ecosystem• Operating systems
• Virtually any distribution with a 2.6.32+ kernel• Red Hat/Docker collaboration to make work across RHEL 6.4+, Fedora, and other members of the family (2.6.32 +)• CoreOS—Small core OS purpose built with Docker
• OpenStack• Docker integration into NOVA (& compatibility with Glance, Horizon, etc.) accepted for Havana release
• Private PaaS• OpenShift• Solum (Rackspace, OpenStack)
• Public PaaS• Deis, Voxoz, Cocaine (Yandex), Baidu PaaS
• Public IaaS• Native support in Rackspace, Digital Ocean,+++• AMI (or equivalent) available for AWS & other
• DevOps Tools• Integrations with Chef, Puppet, Jenkins, Travis, Salt, Ansible +++
• Orchestration tools• Mesos, Heat, ++• Shipyard & others purpose built for Docker
• Applications• 1000’s of Dockerized applications available at index.docker.io
Driver$Interface
• Abstract(Interface(to(interact(with(the(underlying(implementation
type(driver(Interface({Run((c(*Command,(…)Kill((c(*(Command)Pause((c(*Command)Name()GetProcessIdsForContainer (id(string)Terminate(()
}
Run Docker ?$ sudo docker run ubuntu:14.04 /bin/echo 'Hello world’Hello world
sudo docker run -t -i ubuntu:14.04 /bin/bashroot@73a19a637b54:/# lsbin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmpusr var
Ubuntu 14.04$ sudo apt-get update$ sudo apt-get install –y docker.io$ sudo ln –sf /usr/bin/docker.io /usr/local/bin/docker$ sudo sed –I ‘$acomplete –F _docker docker’ /etc/bash_completion.d/docker.io
Ubuntu 14.04 – Docker Official Release (New)$ sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 36A1D7869245C895$ sudo bash –c “echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list$ sudo apt-get update$ sudo apt-get install lxc-docker
Get Image$ sudo docker pull ubuntu:14.04Pulling repository ubuntu07f8e8c5e660: Download completee9e06b06e14c: Download completea82efea989f9: Download complete37bea4ee0c81: Download complete
Get Image From Specific Server$ sudo docker pull dl.dockerpool.com:5000 ubuntu:14.04Pulling repository ubuntu07f8e8c5e660: Download completee9e06b06e14c: Download completea82efea989f9: Download complete37bea4ee0c81: Download complete
List Images$ sudo docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEubuntu 14.04 07f8e8c5e660 2 weeks ago 188.3 MB
What$is$OpenStack
“Open%source software*for*buildingprivate%and%public%clouds”
33OpenStack*Foundation
OpenStack$Projects
• Core Projects• Nova (Compute Service)• Glance (Image Service)• Neutron (Network Service)• Cinder (Block Storage Service)• Swift (Object Storage Service)
• Common Projects• Keystone (Identity Service)• Horizon (Dashboard)• Ceilometer (Telemeter Service)• Heat (Orchestration Service)
• Shared Modules• Oslo (Shared Infrastructure Code)
• Incubation Projects• Magnum (Container Service)
OpenStack$Project
• Each project is a “top-level” OpenStack part• Each project has a “Project Technical Leader” (PTL)• Each project has different developers and designers• Each project has well designed public API• Except Horizon, it’s a WEB UI• All other project provide a RESTful API( JSON/HTTP)
• Each project has isolated database
OpenStack$CommunicationUI:%Horizon%/%CLI
Cinder%API
Scheduler
Cinder%DB
Queue
Cinder
Cinder%Vol
Nova%API
Scheduler
Conductor
Nova%Cell
Queue
Nova%DB
Nova
Nova
Nova@Compute
Nova Hypervisor
Compute/Node
VM
Network
Router/GW
DHCP/IPAM
Network/Node
Storage
Block/Storage/Node
Glance%API
Glance%Registry
Glance%DB
Glance
Proxy%Server
Object%Store
Swift
Plugin% /Agent
Neutron%DB
Neutron%Server
Neutron
Plugin%/Agent
Keystone%Server
Keystone%DB
Keystone