contain yourself

38
Contain Yourself Contain Yourself Intro to Docker and Containers

Upload: vuanh

Post on 13-Feb-2017

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Contain Yourself

Contain Yourself Contain Yourself Intro to Docker and Containers

Page 2: Contain Yourself

Nicola Kabar

|| [email protected] Architect at DockerHelp Customers Design Solutionsbased on Docker<3 Python, RESTful APIs, Containers

Mano Marks

|| [email protected] Relations Director atDocker Help Developers use Docker<3 Geographic Information Systems,

Mobile, and Containers

@nicolakabar

@ManoMarks

Page 3: Contain Yourself

Agenda

Background InfoWhat is Docker ?How Does Docker Work?Docker In Action (Demo!)Why Docker?Getting StartedQ/A

Page 4: Contain Yourself

Let's startLet's startwith somewith somehistory....history....

Page 5: Contain Yourself

Traditional Architecture (Traditional Architecture (pre-2000pre-2000))One Server = One ApplicationSingle Stack = Single LanguageMore compute = More serversExpensive, Slow, Inefficient

Page 6: Contain Yourself

Virtualization (2000s)Virtualization (2000s)

One Server = Multiple VMs =Multiple Stacks = MultipleApplicationsMore compute = More VMs10s of VMs per ServerEnabled Cloud Computing

Page 7: Contain Yourself

GREAT GREAT

But it's Complex,Heavy,and Expensive!But it's Complex,Heavy,and Expensive!

Page 8: Contain Yourself
Page 9: Contain Yourself
Page 10: Contain Yourself
Page 11: Contain Yourself

Containerization=Containerization=Operating System VirtualizationOperating System Virtualization

Lightweight Isolated RunnablePortableNew Way to PackageEverything that an App needsto run

Page 12: Contain Yourself
Page 13: Contain Yourself
Page 14: Contain Yourself

So What Exactly is Docker ?So What Exactly is Docker ?

"open platform toeasily build,ship,runlightweight,portable,self-sufficient appcontainersanywhere."

Page 15: Contain Yourself

Engine

Client

Registry

Images

Containers

Page 16: Contain Yourself

EngineEngine

Daemon on Host Linux or Windows*Build ImagesPull ImagesPush ImagesRun ContainersManage ContainersHTTP REST API

*To Be Supported in Windows Server 2016

Page 17: Contain Yourself

ClientClient

Use HTTPInstalled with EngineLocal or Remote CallsGUI vs CLI

Page 18: Contain Yourself

Basic Docker Commands

$docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES04a335b35403 busybox "/bin/sh -c 'while tr" 1 seconds ago Up 1 seconds suspicious_fermi

$docker versionClient: Version: 1.8.2 API version: 1.20 Go version: go1.4.2 Git commit: 0a8c2e3 Built: Thu Sep 10 19:19:00 UTC 2015 OS/Arch: linux/amd64

Server: Version: 1.8.2 API version: 1.20 Go version: go1.4.2 Git commit: 0a8c2e3 Built: Thu Sep 10 19:19:00 UTC 2015 OS/Arch: linux/amd64

$docker run busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"Hello WorldHello WorldHello WorldHello World

$docker infoContainers: 15Images: 220Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 250 Dirperm1 Supported: trueExecution Driver: native-0.2Logging Driver: json-fileKernel Version: 3.19.0-26-genericOperating System: Ubuntu 14.04.3 LTSCPUs: 1Total Memory: 993.2 MiBName: dev1ID: OXRP:6VZL:PLXK:Y7SU:EFEI:2KF5:PILP:UKXHDebug mode (server): true

Page 19: Contain Yourself

ImagesImagesRead-Only Collection of FilesParent ImageBase Image (OS-like)Immutable + ReusableUnion File System (UFS)

Page 20: Contain Yourself

ContainersContainers

"VM-like"Run Isolated Processes in

Read-Write Layer

Created from an ImageCopy-On-Write (COW)

Page 21: Contain Yourself

How is it Possible?How is it Possible?Linux Kernel Features --> Isolation

namespaces:pid,user,network,ipc --> What Can You See

cgroups:cpu,memory, disk I/O -->What Can you Use

UFS + COW --> Speed + Disk Utilization

Page 22: Contain Yourself

Building ImagesBuilding ImagesProcess of creating,altering, and committingcontainersThree Options:

Manual Run + CommitImport tarballDockerfile

# A basic Apache+PHP ImageFROM ubuntu:12.04

MAINTAINER Nicola Kabar version: 0.1

RUN apt-get update && apt-get install -y apache2

RUN apt-get install -y php5

ENV APACHE_RUN_USER www-dataENV APACHE_RUN_GROUP www-dataENV APACHE_LOG_DIR /var/log/apache2

RUN rm -rf /var/www/*ADD index.php /var/www/

EXPOSE 80

CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]

docker run -it ubuntu:12.04root@05bfafc8e5a8:/# apt-get -y install apache2...<snippit>....root@05bfafc8e5a8:/# exitdocker commit 05bfafc8e5a8 myimage1ae55d7aacc0ca202

$docker build -t myimage .

Page 23: Contain Yourself

Image Building Process

Ubuntu

Page 24: Contain Yourself

RegistryRegistry

Image Distribution Cloud Version: Docker Hub (hub.docker.com)Official ImagesTeam CollaborationWorkflow Automation

Page 25: Contain Yourself
Page 26: Contain Yourself

Docker In Action Docker In Action 1. Run a Container2. Build An Image from Dockerfile3. Push the Image to Docker Hub4. Pull the Image from Docker Hub5. Run a Container from the Image

Page 27: Contain Yourself

so whyso whyDocker ?Docker ?

Page 28: Contain Yourself

Docker StatsDocker StatsWritten in Go(lang)Open-sourced in March,2013 (github.com/docker/docker)1300+ ContributorsDocker Jobs Openings 43,000+ (*)150,000+ Dockerfiles on Github90,000+ Repositories on Docker Hub100s of Millions of Images DownloadedMillions of Developers Use It90+ Official Images

*source: indeed.com

Page 29: Contain Yourself

Killer Features of Docker Killer Features of Docker

SpeedLightweightReliable DeploymentPortability...

Page 30: Contain Yourself

Changing Software ArchitectureChanging Software Architecture

Page 31: Contain Yourself

Use CasesUse Cases

DevelopmentTestingProduction

Page 32: Contain Yourself

Docker registry of research algorithms

Research reproducibility

Standard interface for DNA Analysis

Page 33: Contain Yourself

Getting StartedGetting Started

with Docker with Docker

Page 34: Contain Yourself

Installing Docker Engine and Docker Toolbox

#ubuntu/debian --> apt-getapt-get install docker-engine

#rhel/centos --> yumyum install docker-engine

Linux Mac/PC

Page 35: Contain Yourself
Page 36: Contain Yourself
Page 37: Contain Yourself

Plot Twist!Plot Twist! Presenting from a Docker Container!

$docker run -d -P nicolaka/cs50

Page 38: Contain Yourself

Thank you!Thank you!

www. .com $docker run -d -P nicolaka/cs50

@nicolakabar@manomarks

Slides: