Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Docker Training
liangbo@trystack.cn
Docker Introduction & WORKSHOP
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 r
S OcM k8 l
o n O e n gtu
e S p 8 o
a G P 8y
h
liangbo@trystack.cn
http://github.com/onetown
http://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 Introduction
Docker For Beginners
Docker is an open platform for developers and sysadmins tobuild, ship, and run distributed applications.Consisting ofDocker Engine, a portable, lightweight runtime and
packaging tool, and Docker Hub, a cloudservice for sharing applications and automating workflows,Docker enables apps tobe quickly assembledfrom components and
eliminates the frictionbetweendevelopment,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 Runany application,anywhere
04
Looking for Help
https://docs.docker.com
02
Learning
Docker consists of:
The Docker Engine - our lightweight and powerful open source container
virtualization technology combined witha work flow for building and
containerizing your applications.
Docker Hub - our SaaS service for sharing and managing your application
stacks.
01
Installation
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 versionor a newer maintained version are also
acceptable.
The$Challenge
Static website
Web frontend
User DB
Queue Analytics DB
Backgroundworkers
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
PublicCloud
Disaster recovery
Contributor’slaptop
ProductionServers
MultiplicityofStacks
Multiplicityof
hardware
environments
ProductionCluster
CustomerData Center
Doservicesandapps
interactappropriately?
CanImigratesmoothly
andquickly?
Application$Matrix
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
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Explanation
• High Level—It’s a lightweight VM
• Own process space
• Own network interface
• Can run stuff asroot
• Can have itsown/sbin/init (different from
host)
• <<machine container>>
• Low Level—It’s chroot on steroids
• Can alsonot have itsown/sbin/init
• Container=isolatedprocesses
• Share kernelwithhost
• Nodevice emulation (neither HVM nor PV)
fromhost)
• <<application container>>
• Runeverywhere
• Regardless of kernel version (2.6.32+)
• Regardless of host distro
• Physical or virtual, cloudor not
• Containerand host architecturemust
match*
• Run anything
• If it can run onthe host,it canrun in the
container
• i.e. if it can run ona Linuxkernel, it can run
WHY WHAT
Introduction
• Docker is an open-sourceengine that automatesthe deployment of any application as a
lightweight, portable, self-sufficient container that will runvirtually anywhere.
• Based onLXC (Linux Container), easy to use.
• Similar to VM asend-user with different features.
• Founded in 2013 (dotCloud)
• Joined Linux Foundation
• Apache 2.0 License
• Implemented by Golang
Virtual$Machine
Docker
Bins/
Libs
App
A
Original App
(No OS to take
up space, resources,
or require restart)
AppΔ
Bins/
App
A
Bins/
Libs
App
A’
Guest
OS
Bins/
Libs
Modified App
Copy onwritecapabilities
allow
us to onlysave the diffs
Between container A and
container
A’
VMs
Every app, every copy ofan
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
Basic$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
Docker Engine
Docker
Container
Image
Registry
Docker Engine
Push
Update
Bins/
Libs
App
A
AppΔ
Bins/
Base
Container
Image
Host is now runningA’’
Container Mod
A’’
AppΔ
Bins/
Bins/
Libs
App
A
Bins/
Bins/
Libs
App
A’’
Host runningA wantsto upgradetoA’’. Requests
update.Gets only diffs
Container Mod
A’
Ecosystem
• Operatingsystems
• Virtually anydistribution with a 2.6.32+ kernel
• Red Hat/Docker collaboration to makework acrossRHEL 6.4+, Fedora, and other membersof thefamily (2.6.32 +)
• CoreOS—Small coreOS purposebuilt 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
• Integrationswith Chef, Puppet, Jenkins, Travis, Salt, Ansible+++
• Orchestration tools
• Mesos, Heat, ++
• Shipyard &otherspurposebuilt for Docker
• Applications
• 1000’s of Dockerized applications available at index.docker.io
Working with Container
!
Docker module 1
Native$Driver
Docker module 1
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/bash
root@73a19a637b54:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp
usr var
Installation
!
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 –keyserverhkp://keyserver.ubuntu.com:80 –recv-keys36A1D7869245C895
$ sudo bash –c “echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get installlxc-docker
Working with Image
!
Get Image
$ sudo docker pull ubuntu:14.04
Pullingrepositoryubuntu
07f8e8c5e660:Downloadcomplete
e9e06b06e14c: Downloadcomplete
a82efea989f9: Downloadcomplete
37bea4ee0c81: Downloadcomplete
Get Image From Specific Server
$ sudo docker pull dl.dockerpool.com:5000 ubuntu:14.04
Pullingrepositoryubuntu
07f8e8c5e660:Downloadcomplete
e9e06b06e14c: Downloadcomplete
a82efea989f9: Downloadcomplete
37bea4ee0c81: Downloadcomplete
List Images
$ sudo docker images
REPOSITORY TAG IMAGEID CREATED VIRTUAL SIZE
ubuntu 14.04 07f8e8c5e660 2weeks ago 188.3MB
OpenStack Integration
!
Docker module 1
OpenStack Introduction
!
What$is$OpenStack
“Open%source software*for*building
private%and%public%clouds”
33OpenStack*Foundation
OpenStack$Projects
• Core Projects
• Nova(Compute Service)
• Glance (Image Service)
• Neutron (Network Service)
• Cinder (Block StorageService)
• Swift (Object StorageService)
• 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
• Eachproject is a “top-level” OpenStack part
• Eachproject has a “Project TechnicalLeader” (PTL)
• Eachproject has different developers and designers
• Eachproject has well designed public API
• Except Horizon, it’s a WEB UI
• Allother project providea RESTful API(JSON/HTTP)
• Eachproject has isolated database
OpenStack$Project
OpenStack$Classic$Deployment
OpenStack$Communication
UI:%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
Hyperviso
r
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
Compute$Scheduler
Compute$Driver
Container
Container
Container
Docker
Demo - Nova Driver – (Docker as compute
Service)
!
Demo - Glance as Docker Image Registry
!
Questions?

More Related Content

Docker module 1