docker - lightweight virtualization

23

Upload: mehdi-hasan

Post on 06-May-2015

1.901 views

Category:

Technology


1 download

DESCRIPTION

Docker - Lightweight Virtualization with Containers

TRANSCRIPT

Page 1: Docker - Lightweight Virtualization
Page 2: Docker - Lightweight Virtualization

Why?

Page 3: Docker - Lightweight Virtualization

That eternal crap…!(i.e Having no idea what’s wrong)

Page 4: Docker - Lightweight Virtualization

Passing on the headache!Not the solution

Page 5: Docker - Lightweight Virtualization

Some use cases• Solving dependency hell • Configure once, run anywhere • Continuous integration • Create sandboxed app • Run your own PaaS

Page 6: Docker - Lightweight Virtualization

So, what’s Docker anyway?

Page 7: Docker - Lightweight Virtualization

Isolation Portability

Provisioning

Hypervisors/VM

Chef, Puppet, Ansible

Your app, libraries

Docker

Page 8: Docker - Lightweight Virtualization

Docker vs. VMHardwareLinux/Kernel

Container Container

Container Container

Container Container

HardwareLinux/Kernel

VMLinux/Kernel

VMLinux/Kernel

VMLinux/Kernel

VMLinux/Kernel

Shared Resource, Lightweight, Portable, Fast to boot

Dedicated Resource, Heavy, Not portable, Comparatively slower boot

Page 9: Docker - Lightweight Virtualization

Under the HoodLXC

Dream inside dream inside dream….

(The Inception in Linux)

Namespaces & cgroups

Isolated pid, net, uid….

Copy-on-write

FilesystemAUFS, btrfs, ZFS….

Page 10: Docker - Lightweight Virtualization

InstallationDo It Yourself

Page 11: Docker - Lightweight Virtualization

Docker Vocabulary

• Repository

• Image

• Tag

$ docker images ubuntuREPOSITORY TAG IMAGE ID ubuntu 10.04 9cc9ea5ea540 ubuntu 12.04 9cd978db300e ubuntu 12.10 5ac751e8d623 ubuntu 13.04 eb601b8965b8 ubuntu 13.10 9f676bd305a4 ubuntu latest 9cd978db300e ubuntu lucid 9cc9ea5ea540 ubuntu precise 9cd978db300e ubuntu quantal 5ac751e8d623 ubuntu raring eb601b8965b8 ubuntu saucy 9f676bd305a4

Page 12: Docker - Lightweight Virtualization

Docker Vocabulary

• Registry $ docker pull ubuntu:12.04Pulling repository ubuntu c0fe63f9a4c1: Pulling dependent layers 511136ea3c5a: Download complete 6170bb7b0ad1: Download complete 79fdb1362c84: Downloading [===> ]56 MB/66.64 MB 10m9s

Page 13: Docker - Lightweight Virtualization

Docker Vocabulary

• Index $ docker loginUsername: mehdi Password: Email: [email protected] Login Succeeded

Page 14: Docker - Lightweight Virtualization

Docker Vocabulary• Container

$ docker run ubuntu:12.04 echo Hello WorldHello World

$ docker run -i -t ubuntu:12.04 /bin/bashroot@a09d485c9a9f:/# uname -a Linux a09d485c9a9f 3.13.3-tinycore64 #1 SMP Wed Mar 26 03:16:13 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux !root@a09d485c9a9f:/#

$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS !f0638f0a1c7a ubuntu:12.04 /bin/bash 46 minutes ago Up 4 seconds

Tip: Press Ctrl+P and Ctrl+Q to detach running containers

Page 15: Docker - Lightweight Virtualization

Docker Vocabulary• Dockerfile $ cat Dockerfile

FROM ubuntu:12.04!!MAINTAINER Mehdi Hasan "[email protected]"!!RUN apt-get -y install python-software-properties!RUN add-apt-repository ppa:chris-lea/node.js!RUN apt-get update!RUN apt-get -y install python g++ make nodejs!

$ docker build -t mehdi/nodejs .There is a trailing dot

$ docker push mehdi/nodejsImage c0fe63f9a4c1 already pushed, skipping Image 5ff6986cd174 already pushed, skipping Image 3867fae91348 already pushed, skipping Image 4574f80c91e4 already pushed, skipping Image 37c2cc34fa4e already pushed, skipping 757db77867dd: Image successfully pushed Pushing tag for rev [757db77867dd] on {https://registry-1.docker.io/v1/repositories/mehdi/nodejs/tags/latest}

Any idea why these images are skipped?

Page 16: Docker - Lightweight Virtualization

Container vs. Image!Still Puzzled?

Running container from an image:

Creating image from a container:$ docker ps -a!$ docker commit -m “Image description" <CONTAINER_ID> <USERNAME>/<REPO>

$ docker run -i -t ubuntu:12.04 /bin/bash

Lets see a Demo

Page 17: Docker - Lightweight Virtualization

Docker Workflow

Dev ProdRegistry

Public/Private

Page 18: Docker - Lightweight Virtualization

DemoDeploying a sample app on the cloud using Docker

Page 19: Docker - Lightweight Virtualization

Your Next Weekend Fun Project: Deploy something with Dokku

DokkuDocker powered mini-Heroku in around 100 lines of Bash

See the demo here: http://vimeo.com/68631325

https://github.com/progrium/dokku

Page 20: Docker - Lightweight Virtualization

The rabbit hole goes deeper than that…

• How to deal with data, logs, file uploads? Where to store? Inside container? Inside host? Inside another container?Hint: Read http://docs.docker.io/en/latest/use/working_with_volumes/

• How to deal with distributed systems? Hint: Follow http://www.centurylinklabs.com/category/docker-posts/

Page 21: Docker - Lightweight Virtualization

Keep following…

• https://coreos.com/

• http://www.confd.io/

• http://www.serfdom.io/

• http://www.dockerbook.com/ (Not yet released)*

* As of May, 2014

Page 22: Docker - Lightweight Virtualization

Docker cheat sheet

• https://gist.github.com/wsargent/7049221

• https://coderwall.com/p/2es5jw

Page 23: Docker - Lightweight Virtualization

Questions?