introduction into docker ecosystem
TRANSCRIPT
Introduction into Docker Ecosystem
Oleksandr Pastukhov JUG Shenzhen August 2016
Who am I? Senior Software developer in EPAM SZ Father and Husband. StartUp ideas generator. Could sell
any by 1$
Docker as a Solution For Developer For Administrator Container vs VM Docker Basics Kitematic Docker in Numbers Orchestration Bonus
Agenda
Docker as a Solution
The Matrix From Hell
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Development VM QA Server
Single Prod
ServerOnsite Cluster
Public Cloud
Contributor’s laptop
Customer Servers
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Also a matrix from hell
Mul
tipl
icit
y of
Goo
dsM
ulti
pilic
ity
of m
etho
ds
for
tran
spor
ting
/sto
ring
Do I w
orry about how
goods interact (e.g. coff
ee beans next to
spices)
Can I transport quickly and sm
oothly(e.g. from
boat to train to
truck)
Cargo Transport Pre-1960
Mul
tiplic
ity o
f Go
ods
Mul
tiplic
ity o
f m
etho
ds fo
r tra
nspo
rting
/sto
ring
Do I worry about how goods
interact (e.g. coffee beans
next to spices)
Can I transport quickly and sm
oothly(e.g. from
boat to train to truck)
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 frontend User DB Queue Analytics DB
Development VM
QA server Public Cloud Contributor’s laptop
Docker is a shipping container system for code
Mul
tiplic
ity o
f St
acks
Mul
tiplic
ity o
f ha
rdwa
re
envi
ronm
ents
Production Cluster
Customer Data Center
Do services and apps interact
appropriately?
Can I migrate
smoothly and quickly
…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…
The Matrix From Hell
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Development VM QA Server
Single Prod
ServerOnsite Cluster
Public Cloud
Contributor’s laptop
Customer Servers
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Development VM QA Server
Single Prod
ServerOnsite Cluster
Public Cloud
Contributor’s laptop
Customer Servers
Docker eliminates the matrix from Hell
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 compatibility 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? That’s the power of Docker
Why Developers Care
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 improves the speed and reliability of continuous
deployment and continuous integration systems. Because the containers are so lightweight, address significant
performance, costs, deployment, and portability issues normally associated with VMs.
Why Administrators Care
Containers vs. VMs
AppA
Containers vs. VMs
Hypervisor (Type 2)Host OSServer
GuestOS
Bins/Libs
AppA’
GuestOS
Bins/Libs
AppB
GuestOS
Bins/Libs
App A’
Docker
Host OSServer
Bins/Libs
App ABins/Libs
App B
App B’
App B’
App B’VM
Container
Containers are isolated,but share OS and, whereappropriate, bins/libraries
GuestOS
GuestOS
…result is significantly faster deployment, much less overhead, easier migration, faster restart
Why are Docker containers lightweight?
Bins/Libs
AppA
Original App(No OS to takeup space, resources,or require restart)
App Δ
Bins/
AppA
Bins/Libs
AppA’
GuestOS
Bins/Libs
Modified AppCopy 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 ofApp
No OS. CanShare bins/libs
AppA
GuestOS
GuestOS
VMs Containers
What are the basics of the 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 PullRun
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’
Containers vs VMs?Better Together!
Docker Basics
Background Image
docker info - basic info about docker machinedocker stats - live stream containers statisticsdocker images - list imagesdocker ps - running containersdocker events - logs from docker machine
docker stop <containerid> - start containerdocker start <containerid>
kill | pause | unpause | restart
Commands
Background Image
docker rm <containerid>docker rmi <imageid>
docker port <containerid> - mapped portsdocker inspect <containerid> - container infodocker top <containerid> - processesdocker exec <containerid> command -in the running containerdocker run <containerid> command -in the new container docker logs <containerid> - last logsdocker attach <containerid> - to see container logs realtime
Commands
Background Image
docker build <dockerfile>docker search - in the hub for imagesdocker create <imgname>- new container from image docker export –o <filename> <containerid> – fs to tardocker import - fs from tardocker load <image >- image from tardocker save <image> - images to tardocker rename - container
Commands
Background Image
Registrydocker login - to docker registrydocker logoutdocker commit - Create image from containerdocker diff - changes uncommitteddocker history - of changesdocker pull / push – image
docker cp - copy between containers
Commands
Background Image
docker network connect disconnect inspect ls rm createvolume - manage volumes create
inspect ls rm
Commands
Kitematic
Docker in Numbers
Docker Ecosystem
1. Docker under Raspberry Pi2. Set up a game server
Bonus