apt get no more let vagrant, puppet and docker take the stage

118
ROME 27-28 march 2015 Alessandro Cinelli (cirpo) Apt-get no more let Vagrant, Puppet and Docker take the stage

Upload: alessandro-cinelli

Post on 16-Jul-2015

482 views

Category:

Software


0 download

TRANSCRIPT

ROME 27-28 march 2015

Alessandro Cinelli (cirpo)

Apt-get no more let Vagrant, Puppet and Docker take the stage

“it works on my machine”

Titlesubtitle

“Everything is written in the

README”

“Everything is written in the wiki”

Titlesubtitle

“oh shit, I forgot to update XYZ”

Titlesubtitle

“cool this opensource project on github… how can I run it?”

“I don’t f*#c?ing care about the platform,

I want to build something cool

NOW!”

SOLUTIONS?

REMOTE MACHINES

https://www.flickr.com/photos/mysterybee/1659329016

VIRTUAL MACHINES

BUT VIRTUAL MACHINES COULD BE

HUUUUUUGE

enter

“Create and configure lightweight, reproducible, and portable development

environments.”

YOU CAN HAVE A VM WITH FEW Kbs

download and install vagrant

download and install vagrant

create a Vagrantfile

download and install vagrant

create a Vagrantfile

run “vagrant up”

download and install vagrant

create a Vagrantfile

run “vagrant up”

enjoy

VagrantFile

VagrantFilevm box name

VagrantFile

base box urlvm box name

VagrantFile

base box urlvm box name

vm ip

VagrantFile

base box urlvm box name

vm ipshared folder

VagrantFile

base box urlvm box name

vm ipshared folder

vm ram

VagrantFile

base box urlvm box name

vm ipshared folder

vm ramvm #cpus

BOXES

BOXES

AUTOMATE SETUP

PROCESS

(PROVISIONING)

PROVISIONERS

VM

$ vagrant up

provisioners

$ ssh

thanks Rohit Dantas

https://github.com/joindin/joindin-vm

how to automate the provisioning?

X

IF THE STACK DOESN’T CHANGE TOO MUCH JUST PROVIDE A READY MADE VM MACHINE… THE PROVISIONER WILL ONLY CHANGE CONFIG FILES

BUILD A NEW MACHINE IF YOU HAVE TO UPGRADE/ADD A SERVICE

“Operating-system-level virtualisation is a virtualisation method where the kernel of an

operating system allows for multiple isolated user space instances, instead of just one.

Such instances, often called CONTAINERS, or jails, may look and feel like a real server from

the point of view of its owners and users.”

http://en.wikipedia.org/wiki/Docker_%28software%29

lego

ONE CONTAINER =

ONE COMMAND

DIFFERENCE BETWEEN A VM AND DOCKER

HOST OS

GUEST OS

HYPERVISOR

BIN/ LIBS

APP A

APP CAPP B

GUEST OS

BIN/ LIBS

APP Z

APP HAPP B

GUEST OS

BIN/ LIBS

APP A

APP DAPP L

HOST OSDOCKER ENGINE

BIN/ LIBS

APP ABIN/ LIBS

APP ZBIN/ LIBS

APP DBIN/ LIBS

APP B{ {

VM

VS

(VM)

FIGHT IMAGE

environment dev all (dev, staging, live)

boot speed minutes seconds

host dependency almost everywhere linux

VS

Full isolation and garanteed resources ?

Then go with vagrant/VM

VS

Isolated processes and tons of them?

Then go with Docker

THE DOCKER CREW INVENTED CONTAINERS?

THE DOCKER CREW INVENTED CONTAINERS?

no

THE DOCKER CREW INVENTED CONTAINERS?

NO

Linux CONTAINERS (LCX)

came from FreeBsd jails and chroot, at least 5 years ago

used by Heroku(PaaS)

Docker is a great, super mega awesome way to orchestrate containers

numbers

DIFFERENCE BETWEEN DOCKER AND A VM

WITH DOCKER YOU DON’T HAVE THE

OVERHEAD GIVEN BY THE VIRTUALISATION

DockerFile

DockerFilecontainer image

DockerFilecontainer image

commands while building the container }

DockerFilecontainer image

commands while building the container

copy some content while building the container

}

DockerFilecontainer image

commands while building the container

copy some content while building the container

declare a volume: data accessible by other containers and useful to mount a filesystem

}

DockerFilecontainer image

commands while building the container

copy some content while building the container

declare a volume: data accessible by other containers and useful to mount a filesystem

environment variable

}

DockerFilecontainer image

commands while building the container

copy some content while building the container

declare a volume: data accessible by other containers and useful to mount a filesystem

environment variablecontainer port exposed to other containers

}

DockerFilecontainer image

commands while building the container

copy some content while building the container

declare a volume: data accessible by other containers and useful to mount a filesystem

environment variablecontainer port exposed to other containers

the container command executed when you run it

}

Build the container:

$: docker build -t node-app .

Run the container:

$: docker run -it node-app

Build another container:

$: docker build -t my-redis .

Run the container:

$: docker run -it my-redis

Link them and enjoy:

$: docker run --link my-redis:redis -p 9200:9200 -d node-app

DEMO

windows 98 bsod

+

why vagrant and docker?

YES YOU CAN!

Docker still requires Linux kernel 3.8 or higher.

This bounds considerably the environments Docker can

natively run on.

BUT YOU SHOULDN’T…

docker-compose (prev fig)

dubai

dubai

namshi

namshinamshi

SOA

Service Oriented Architechture

DOCKER IS A PERFECT MATCH!

DOCKER IS A PERFECT MATCH!

EVEN FOR DEVELOPMENT

fake service? no problemDO YOU NEED TO FAKE A

SERVICE?

NO PROBLEM, JUST SPIN UP A CONTAINER IN NO TIME

NGINX-PROXY

https://github.com/jwilder/nginx-proxy

APIDOC (DEMO)

APIDOC (DEMO)

NGINX-PROXY

DOCKER PROSMatter of seconds to start an image

Can start multiple copies immediately

Central repo for images

You can go on staging and live from dev with the same container

Versioning

DOCKER CONS

It really works really well just on Linux atm

It’s a young project, things change very fast

Lack of proper management tool

DOCKER CONS

It really works really well just on Linux atm

It’s a young project, things change very fast

Lack of proper management tool

boot2docker

Kitematic

github.com/namshi/node-dock

node-dock

NODE-DOCK

Docker disk space cleanup

$: docker rm $(docker ps -a -q)

$: docker images | grep "<none>" | awk '{ print "docker rmi " $3 }' | bash

https://github.com/dummymael/dotfiles/blob/1859a36afba2252f86a0a1ff8d5fb442e74b7a0e/tools/

docker_clean_vfs.py

$: pip install docker-py

@cirpo

github.com/cirpo

/

THANKS!

credits

http://blog.docker.com/media/Docker_Infographic_FINAL.jpg

https://www.flickr.com/photos/chuddlesworth/7059061549

Tim Haak https://speakerdeck.com/timhaak/vagrant-is-so-last-year-why-arent-you-using-docker-yet

Rohit Dantas https://speakerdeck.com/rohitdantas