Upload
frei-zhang
View
422
Download
0
Embed Size (px)
DESCRIPTION
Introduction to docker
Citation preview
Introductionto Docker
Frei Zhang
0
Virtualization TechOverview
To get start, let's take a glance of virtualizationtechnology.
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
Types of virtualization
Hardware / Platform virtualizationFull virtualizationPartial virtualizationParavirtualizationOS-Level virtualization
Resource virtualizationStorage, Network, Memory …
Application virtualizationPortable app, App sandbox
BenefitsLower infrastructure, energy, and facility costs.High service level and availabilityGreater utilization of infrastructure investmentsEnhance IT securityFast and flexible scalabilityLess administration overheadRapid deployment.
What is Docker?
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.
Popularity
How it works?
Architect overviewclient-server applicationClient and Server can run on the same system orseparately (local or distributed)Communicate via socket or RESTful API
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. ;)
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.
cgroupAlso called control groups. it allow Docker to set up
resource sharing limit.
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.
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.
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.
Why dockerLess configurationEasy deployModularization everythingLight weightApp isolation…
Real world exampleWhen you join in a new project(leap frog?), you need:
install && configure suitable IDE, toolsresolve library dependenciessetup build environment
Don't panicDocker will do them for you, just create a docker
image, and deploy every where.Let's see more.
Docker Work flow
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
Docker build, image
create image from container
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 .
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.
try itTalk is cheap, show me the docker!
The EndQA
EmacsI'm a big fan of Emacs.