Introduction to docker

Post on 26-Jan-2015

593 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

Transcript

Introduction to Docker

@endhrk

Agenda

● What Is Docker● How To Use Docker

– How Do I Install Docker

– How Do I Use Docker

– How Do I Build containers

– How Do I Terminate

● Important Docker terms● Consisting Of Docker Engine

– Lightweight

– Portable

– Packaging

What Is Docker

● Open platform● For developers and system administrators● To build, ship ,run applications

How To Use Docker

● Install● Use● Build● Delete

How Do I Install Docker

*may not be the latest Docker release

**Install for Ubuntu 14.04

$ sudo apt-get -y install docker.io$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker$ sudo gpasswd -a $USER docker

How Do I Use Docker

$ sudo start docker.io$ docker run -i -t ubuntu /bin/bashroot@0f0bd22ce93e:/#

How Do I Build Containers

● DockerfileFROM ubuntu:14.04RUN apt-get -y install apache2EXPOSE 80CMD [“/usr/sbin/apache2ctl”, “-D”, “FOREGROUND”]

$ docker build -t apache .$ docker run -d -P apachef254fc1aa31909783a26fb14f80d75ba128762b605604f95ef9a146de0ee46ed

How Do I Terminate

● Stop container

● Remove container

● Remove all images●

$ docker stop f254fc1aa319

$ docker rmi `docker images -q`

$ docker rm f254fc1aa319

Important Docker Terms● Docker image

– Is Read-only template● ex. contains an Ubuntu with Apache and applications

– Is used to create Docker container

– Provides simple way for delivery

● Docker registry– Holds images

– Provides simple way to upload and download images

– Has public and private● Public is called Docker Hub● Private Docker registry is provided by docker image at Docker Hub.

● Docker container– Is an isolated and secure application platform

– Is created from a Docker image

– Can be run, started, stopped, moved, deleted

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

Why Is Docker Lightweight

● Container virtualization● Union file system

Why Is Docker Lightweight

● Container virtualization● Union file system

What Is Container Virtualization

● Virtualization technology– Hardware virtualization (ex. VMware, Hyper-v)

– Container virtualization (ex. Docker, OpenVZ)

What Are Difference Between Technologies

Hardware virtualization Container virtualization

What is virtualized

Virtualized hardware environment Virtualized OS environment

What can be put on Host

Different OS Different Lib/Bin (kernel is shared)

What is launched

Launch OS Launch process

How to access I/O

Via Virtualized hardware Use directly limited resources

What Are Stacks Difference Between Technologies

Hardware

Hypervisor

Bin/Libs

MW MW MW

App App App

KernelBin/LibsKernel

Bin/LibsKernel

VirtualHardware

VirtualHardware

VirtualHardware

HardwareLinux kernel

Bin/Libs

Docker daemon MW MW

App App

Bin/Libs Bin/Libs

Hardware virtualization Container virtualization

How Much Are Their Performance Difference

CPU Memory fileio0 sec

5 sec

10 sec

15 sec

20 sec

25 sec

30 sec

35 sec

physical

docker

virtualbox

* This benchmark was measured using sysbench

Components ForContainer Virtualization

● Isolation– Identify a set of processes

– Isolate resources

– Don't recognize each other processes

● Resource control– Limit the resources used

* resource = process id, memory, cpu, disk space, network

How To RealizeContainer Virtualization

● Using kernel feature● Isolation via namespace

– PID namespace

– Network namespace

– UTS namespace (hostname etc.)

– IPC namespace

– Mount namespace

● Resource control via cgroups– Resource limiting

– Prioritization process

– Accounting using resources

– Control groups

What Is Meant By Lightweight For Container

● Container virtualization– Launch faster

● launch only process. Kernel was already booted.

– Use resources efficiently● Kernel and memory are shared

– Run process faster● There is no overhead like hardware virtualization

Why Is Docker Lightweight

● Container virtualization● Union file system

What Is Union File System

● Union file system is– Several filesystems to be mounted, appearing to be

one filesystem

● Docker uses aufs– You can choose other option (ex. devicemapper

How Does Aufs Work

1.Mount a base image as read-only

2.Add read-write file system over read-only file system

3.Change some files and directories to top as read-write file system

4.It is committed

5.Save incremental files and directories in new image

6.Mount the image as read-only and add read-write file system on top

How Does Aufs Work

What Is Meant By Lightweight For Union File System

Bin/Libs

MW

App

Image

Bin/Libs

MW

App

Container1

shared

MW

App

Container2

● Owing to use of union file system– Not changed files are shared for each containers

– Storage and memory spaces are saved

– Faster deployment of containers

shared

MW

App

Container3

shared

shared

App

Container4

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

Why Is Docker Portable

● Run anywhere● Simple way to take image to another

environment● Copy Incremental files only

Which Environment Can I Use

● Run anywhere– Any OS?

● ex. Linux, ?Mac OSX?, ?Windows?

– Any Cloud● ex. Google Cloud Platform, Amazon Web Services, SoftLayer

– Any Physical Machine● ex. Your PC, Server for production

*You have to use Docker on Virtualbox if you use Mac OSX or Windows

How Can I Take the Image

● Simple way to take image to another environment– Docker Hub (like GitHub)

● Can set tag (version control)● Easy to push image● Easy to pull image● Allow to access from anyone

– Private registry● Can limit access person who is not allowed● Basic features are same as Docker Hub

What Does Docker Copy

Bin/Libs

MW

App

Bin/Libs

MW

App Diff

Image

Bin/Libs

MW

App

Container

Update

Container

Commit

Diff

Image

Run

Run

Bin/Libs

MW

App Diff

Container● Save only changed files● Push or pull just small increment files

What Is Meant By Portable

● Run anywhere● Simple way to take image to another

environment● Copy Incremental files only

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

What Is Packaged In Docker Image

● Docker image contains– Application

– Middleware required by Application

– Basic programs (like a OS)

– Settings● Application, Middleware, OS(Disk, Network)

● All of things for running Application

What Is Meant By Packaging

● Image contains all of things for running application

● Packaging realize– Portable and reliable application deployments

– Rapid and efficient application delivery

– Simplified application runtime environment

– Coding explicit knowledge

Review

● How to use Docker● Important docker terms● Consisting of Docker Engine

– Lightweight

– Portable

– Packaging

Thanks

top related