Top Banner
Introduction to Jirayut Nimsaeng (Dear) Docker for DevOps and Continuous Delivery Workshop October 11, 2014 @ OSS Festival 2014
35

Introduction to Docker

Nov 27, 2014

Download

Technology

Introduction to Docker slide in Docker for DevOps and Continuous Delivery at OSS Festival 2014 Thailand
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Docker

Introduction to

Jirayut Nimsaeng (Dear)

Docker for DevOps and Continuous Delivery WorkshopOctober 11, 2014 @ OSS Festival 2014

Page 2: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

About me● Jirayut Nimsaeng (Dear)● Infrastructure Team Lead

at Proteus Technologies● Scrum Master● Interested in Cloud and

Open Source Technology

Page 3: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Experienced?● Use Vagrant● Read and tried Docker online tutorial● Install and run Docker locally● Build Docker images● Push Docker images to Docker Hub● Written Dockerfile● Deploy Docker images for dev/test/prod

Page 4: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Developer Problems

Developer Local Test QA

Production

Page 5: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

What Developer needs

Production-like Quick Repeatable

Page 6: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker can solve this problem

Developer Local Test QA

Production

Page 7: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Infrastructure Problems

Page 8: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Shipping with container

Page 9: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker can● Deploy (almost) everything

Page 10: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker can● Deploy (almost) everywhere

Native On VMs

Page 11: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker can● Deploy reliably & consistently● Everything will be exactly the same

– Distros– Versions– Dependencies

● If it works locally, it will work everywhere

Page 12: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

In summary

Page 13: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker can● Deploy efficiently

– Laptop can run 10-100 containers easily– Server can run 10-1000 containers

● Containers can run at native speeds– http://www.slideshare.net/BodenRussell/kvm-and-

docker-lxc-benchmarking-with-openstack

Page 14: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker CPU benchmark

0

2

4

6

8

10

12

14

Docker / KVM: Compute Node Steady-State CPU (Segment Overlay)

docker-usrdocker-syskvm-usrkvm-sys

Time: KVM(95s - 307s) Docker(31s – 243s)

CPU Usage In Percent

Docker Averages

– 0.2

– 0.03

KVM Averages

– 1.91

– 0.36

Page 15: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Memory benchmark

0.00E+00

1.00E+09

2.00E+09

3.00E+09

4.00E+09

5.00E+09

6.00E+09

7.00E+09

Docker / KVM: Compute Node Used Memory (Overlay)

kvmdocker

Axis Title

Memory Used

Page 16: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Memory benchmark

MEMCPY DUMB MCBLOCK0

2000

4000

6000

8000

10000

12000

14000

3823.34393.3

12881.61

3813.38

4395.92

12905.68

3428.95 3461.59

7223.23

Memory Benchmark Performance

Bare Metal (MiB/s)docker (MiB/s)KVM (MiB/s)

Memory Test

MiB/s

Page 17: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker I/O benchmark

1 2 4 8 16 32 640

200

400

600

800

1000

1200

1400

1600

Sysbench Synchronous File I/O Random Read/Write @ R/W Ratio of 1.50

dockerKVM

Threads

Total Transferred In Kb/sec

Page 18: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

What is Docker?● Platform to help code, test and deploy

applications● Combine with

– Lightweight container virtualization– Work flows– Tooling

Page 19: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker image● Docker images are read-only templates● Each image consists of series of layers● Docker use union file system to combine layers

into single image● Every image starts from base image

Page 20: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker image layers

Page 21: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker container● Docker containers launched from Docker image● Container consists of

– Operating system– User-added files– Meta-data

● When Docker container runs, it adds a read-write layer on top of the image

Page 22: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Containers vs. VMs

Server

Host OS

Hypervisor

GuestOS

GuestOS

GuestOS

Bins/Libs

AppA1

Bins/Libs

AppB1

Bins/Libs

AppA2

VM

Server

Host OS

Bins/Libs Bins/Libs

App A

1

App A

2

App B

1

App B

2

App B

3

Docker daem

o n

Container

Containers are isolated,but share OS and, whereappropriate, bins/libraries

Page 23: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Containers more lightweight

GuestOS

GuestOS

GuestOS

Bins/Libs

AppA1

Bins/Libs

AppB1

Bins/Libs

AppA2

VMs Containers

AppA1

AppA2

Δ

App A1 App A2 ModifiedApp

Bins/Libs

Base

Page 24: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker container concept

KernelDocker driver, aufs/btrfs

Host OS (CoreOS)

Ubuntu base Bins/Libs

App A

1

App A

2

Docker daem

o n

Busybox base bins/libs

Python Apache

PHP

MySQL

App B

Dem

o

App B

Prod

Data C

o ntaine r for Ap p A

1App B

CentOS base Bins/Libs

App D

1

App D

2

Python ApacheApache

PHP

App E

Dem

o

App E

Prod

App B

MySQL

Data C

o ntaine r for Ap p A

2

Data C

o ntaine r for Ap p B

Pro d

Data C

o ntaine r for Ap p C

App C

App F

Docker Image Docker ContainerDocker Base Image

Page 25: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Dockerfile● Dockerfile is instructions to build Docker image

– How to run commands– Add files or directories– Create environment variables– What process to run when launching container

● When build Dockerfile, new Docker image will return as a result

● Or we can call result from building Dockerfile is new base Docker image

Page 26: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Sample DockerfileFROM base

MAINTAINER Jirayut Nimsaeng <w [at] winginfotech.net>

ADD build-files /build-files

RUN apt-get update

RUN apt-get install -y openssh-server vim tmux rsync byobu

RUN mkdir /var/run/sshd

RUN sed -i 's/required pam_loginuid.so/optional pam_loginuid.so/g' /etc/pam.d/sshd

CMD /start.sh

EXPOSE 22

Page 27: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Registry● Docker Registry is the store for Docker image● Docker Hub is public Docker Registry like Github● Using Docker client to push and pull Docker image

from Docker Registry● You can create your own Docker Registry

Page 28: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Hub

Page 29: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker life cycle

App ADocker Container

DockerRegistry

PushCommit

Host

App A

1 Contai ner

Pull

Docker Engine

App A

2 Contai ner

App A

Image

App A

Image

UbuntuBase Docker

ApacheDocker Container

Apache + PHPDocker Image

Bins/Libs

Apache

Bins/Libs

Apache

ChangeCommit

App A

ΔΔ

Change

App A

Apache

Bins/Libs

App ADocker image

Page 30: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker workflows

DockerfileFor App A

Host 1 (Dev/Build Server)

Docker Engine

Image A

pp AIm

age App A

DockerRegistry

Host 2 (Container Server)

1.Build

2.Push

3.Pull

4.Run

Docker Engine

Image A

pp A

Contain er A

pp A P

rodu ction

Page 31: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Use Cases● Docker as Development Environment

Host

Virtualbox VM

Docker DaemonSSH

20352022

22

Web Server

boot2docker-vm

80 1024+

Docker Containers

Database

2035

Hos

t-on

ly

80

80

Page 32: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Use Cases● Docker as Infrastructure as a Service

Server

Host OS

Bins/Libs Bins/Libs

App A

App A

~

App B

App B

~

App B

~~

Docker daem

o n

Page 33: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Use Cases● Docker as Platform as a Service

Page 34: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Docker Use Cases● Docker for Continuous Delivery

Page 35: Introduction to Docker

Jirayut NimsaengDocker for DevOps and Continuous Delivery Workshop

October 11, 2014 @ OSS Festival 2014

Continuous Delivery with Docker

MySQLDockerfile

Host 1 (Dev/Build Server)

Docker Engine

MyS

QL D

ata Image

MyS

QL D

ata Image

DockerRegistry

Host 2 (Container Server)

1.Build

3.Push

7.Pull

8.Run

Docker Engine

MyS

QL D

ata Image

Contain er M

ySQ

L Dat a

BackupServer

2.Get DB Backup

WordpressDockerfile4.Build

RepositoryServer

5.Get Wordpress Code

Wordpr ess Im

a geW

ordpr ess Ima ge

6.PushW

ordpr ess Ima ge

Contain er W

or dpress