Top Banner
Introduction to Docker @endhrk
36

Introduction to docker

Jan 26, 2015

Download

Technology

Hiroki Endo

 
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 Docker

@endhrk

Page 2: Introduction to docker

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

Page 3: Introduction to docker

What Is Docker

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

Page 4: Introduction to docker

How To Use Docker

● Install● Use● Build● Delete

Page 5: Introduction to docker

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

Page 6: Introduction to docker

How Do I Use Docker

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

Page 7: Introduction to docker

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

Page 8: Introduction to docker

How Do I Terminate

● Stop container

● Remove container

● Remove all images●

$ docker stop f254fc1aa319

$ docker rmi `docker images -q`

$ docker rm f254fc1aa319

Page 9: Introduction to docker

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

Page 10: Introduction to docker

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

Page 11: Introduction to docker

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

Page 12: Introduction to docker

Why Is Docker Lightweight

● Container virtualization● Union file system

Page 13: Introduction to docker

Why Is Docker Lightweight

● Container virtualization● Union file system

Page 14: Introduction to docker

What Is Container Virtualization

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

– Container virtualization (ex. Docker, OpenVZ)

Page 15: Introduction to docker

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

Page 16: Introduction to docker

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

Page 17: Introduction to docker

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

Page 18: Introduction to docker

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

Page 19: Introduction to docker

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

Page 20: Introduction to docker

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

Page 21: Introduction to docker

Why Is Docker Lightweight

● Container virtualization● Union file system

Page 22: Introduction to docker

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

Page 23: Introduction to docker

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

Page 24: Introduction to docker

How Does Aufs Work

Page 25: Introduction to docker

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

Page 26: Introduction to docker

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

Page 27: Introduction to docker

Why Is Docker Portable

● Run anywhere● Simple way to take image to another

environment● Copy Incremental files only

Page 28: Introduction to docker

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

Page 29: Introduction to docker

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

Page 30: Introduction to docker

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

Page 31: Introduction to docker

What Is Meant By Portable

● Run anywhere● Simple way to take image to another

environment● Copy Incremental files only

Page 32: Introduction to docker

Consisting Of Docker Engine

● Lightweight● Portable● Packaging

Page 33: Introduction to docker

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

Page 34: Introduction to docker

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

Page 35: Introduction to docker

Review

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

– Lightweight

– Portable

– Packaging

Page 36: Introduction to docker

Thanks