31
Introduction to Docker Frei Zhang 0

Docker intro

Embed Size (px)

DESCRIPTION

Introduction to docker

Citation preview

Page 1: Docker intro

Introductionto Docker

Frei Zhang

0

Page 2: Docker intro

Virtualization TechOverview

To get start, let's take a glance of virtualizationtechnology.

Page 3: Docker intro

What is virtualization ?Virtualization, in computing, refers to

the act of creating a virtual (ratherthan actual) version of something,

including but not limited to a virtualcomputer hardware platform,

operating system (OS), storage device,or computer network resources.

– wikipedia

Page 4: Docker intro

Types of virtualization

Page 5: Docker intro

Hardware / Platform virtualizationFull virtualizationPartial virtualizationParavirtualizationOS-Level virtualization

Page 6: Docker intro

Resource virtualizationStorage, Network, Memory …

Page 7: Docker intro

Application virtualizationPortable app, App sandbox

Page 8: Docker intro

BenefitsLower infrastructure, energy, and facility costs.High service level and availabilityGreater utilization of infrastructure investmentsEnhance IT securityFast and flexible scalabilityLess administration overheadRapid deployment.

Page 9: Docker intro

What is Docker?

Page 10: Docker intro

Docker isDocker is an open platform designed for developers

and sysadmins. It's built to help you build applicationsand services and then deploy them quickly and

efficiently: from development to production.

Page 11: Docker intro

Popularity

Page 12: Docker intro

How it works?

Page 13: Docker intro

Architect overviewclient-server applicationClient and Server can run on the same system orseparately (local or distributed)Communicate via socket or RESTful API

Page 14: Docker intro

Inside DockerDocker uses the concept of a Standard Container

which contains a software component along with all itsdependencies - binaries, libraries, configuration files,scripts, virtualenvs, jars, etc. – and can be run on any

x64-bit Linux kernel that supports cgroups.Don't afraid, this part won't be so long. I'll do a simpleexplanation. If you want to know more, read the wiki. ;)

Page 15: Docker intro

namespacewhen you run a container, a set of namespace are

bundled to the container. namespace provides a layerof isolation: each process runs in its own namespace

and does not have access outside it.

Page 16: Docker intro

cgroupAlso called control groups. it allow Docker to set up

resource sharing limit.

Page 17: Docker intro

union fsUnionFS or union filesystems are filesystems that

operate by creating layers, making them verylightweight and fast. Docker uses union filesystems to

provide the building blocks for containers.

Page 18: Docker intro

containerDocker combines these components to build a

container format we call libcontainer. Docker alsosupports traditional Linux containers like LXC which

also make use of these components.

Page 19: Docker intro

TerminologyDocker daemonDocker clientContainer

Your application run inside the containersImage

Your containers are built from images.repository

A repository is a group of images located in thedocker registry

registryServers that store docker repositories for easiersharing.

Page 20: Docker intro

Why dockerLess configurationEasy deployModularization everythingLight weightApp isolation…

Page 21: Docker intro

Real world exampleWhen you join in a new project(leap frog?), you need:

install && configure suitable IDE, toolsresolve library dependenciessetup build environment

Page 22: Docker intro

Don't panicDocker will do them for you, just create a docker

image, and deploy every where.Let's see more.

Page 23: Docker intro

Docker Work flow

Page 24: Docker intro

Basic commands#To run a container$ docker run ubuntu:14.04 /bin/echo Hello World! Hello World!

#List docker images$ docker imagesREPOSITORY TAG ID CREATED SIZEubuntu 14.04 b710fe79369d 3 hours ago 24.65 kB (virtual 320.5 MB)

#Container running state$ docker ps -aID IMAGE COMMAND CREATED STATUS PORTS861361e27501 ubuntu:14.04 /bin/echo hello world 1 minutes ago Exit 0

#Logs$ docker logs b710fe79369d hello world

#Run command interactively # run a shell from ubuntu 14.04$ docker -i ubuntu:14.04 /bin/bash

#Run command as daemon$ docker -d ubuntu:14.04 mysqld

#Attach to running container$ docker -attach 861361e27510

Page 25: Docker intro

Docker build, image

Page 26: Docker intro

create image from container

Page 27: Docker intro

create image from DockerfileAssume that I have just finish leap frog new feature.

And below is my working directory:$ ls...LFFrameworkLibsThirdpartyConfigsResourceMyAwesomeGame

Now Create a Dockfile$ emacs -nw Dockerfile#target osFrom ubuntu:14.04#update sourceRun apt-get update#install depsRun apt-get install box2d bullet mali-dev scons ...COPY . /srcRUN cd /src Scons Awesome-Game#port sharingEXPOSE 8888CMD ["/src/out/Awesome-Game", "-test", "map1"]

#Then build image from this Dockerfile.$docker build -t lf01/awesomegame-alpha .

Page 28: Docker intro

Deploy, sharingUse docker save or docker export to get image file$ docker save lf-01/awesomegame-beta | scp to dist server

On the dist server, the can use docker load or dockerimport to import the image.

$ docker import awesomegame-beta-09-9-14.tar$ docker run lf-01/awesomegame-beta /src/out/Awesome-Game -test map1

P.S. You can launch a docker register server to store,share docker images, but this slide don't cover this

topic. If you are interesting about it, feel free to discusswith me.

Page 29: Docker intro

try itTalk is cheap, show me the docker!

Page 30: Docker intro

The EndQA

Page 31: Docker intro

EmacsI'm a big fan of Emacs.