vagrant & docker

17
Vagrant + Docker Criando ambientes Portáveis entre plataformas João Paraná @joao-parana @joao.parana github: gmail:

Upload: joao-antonio-ferreira-parana

Post on 17-Jul-2015

98 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Vagrant & Docker

Vagrant + DockerCriando ambientes Portáveis entre plataformas

João Paraná

@joao-parana

@joao.parana

github:

gmail:

Page 2: Vagrant & Docker

Introduction

• What is Vagrant?

• Created by Mitchell Hasimoto

• Provisioning Tools for Dev, Production & Test Environments

• Syntactic sugar around VMs and Containers

• Syntactic sugar around provisioning

• Why use Vagrant?

• Quick

• Easily replicate production on a Dev box

• Easily go production from a Dev box

• Mature, stable, proven

Page 3: Vagrant & Docker

Step 1: Install Vagrant

• http://www.vagrantup.com/downloads.html

• Mac OSX

• Windows

• Debian/Ubuntu

• CentosOS/Redhat/Fedora

Page 4: Vagrant & Docker

Step 2: Project Setup

$ mkdir vagrant_getting_started

$ cd vagrant_getting_started

$ vagrant init

Page 5: Vagrant & Docker

Step 3: Select a Box

• http://www.vagrantbox.es

• Ubuntu, OpenSuse, OpenBSD, CentOS, Debian..

• Select Provider (VM or Container)

Page 6: Vagrant & Docker

Step 4: Show/Edit Vagrantfile

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.box = "precise64"

config.vb.box_url = "http://bit.ly/1gLmNF0"

end

Page 7: Vagrant & Docker

Step 5: Up!

$ vagrant up

Step 6: Connect!

$ vagrant ssh

Page 8: Vagrant & Docker

More Commands

• status : status of the machine

• halt : stop machine

• suspend : suspend machine

• reload : restar machine (load new vagrantfile)

• resume : resume suspended machine

• provision : force provisionning machine

• destroy : stop and delete machine

• box : manages boxes

• …

Page 9: Vagrant & Docker

More Providers (native or plugin)

• VMs:

• VirtualBox, KVM, Hyper-V, VMware, libvirt

• Containers:

• lxc, docker

• Services:

• AWS, DigitalOcean, HP Cloud, Joyent,

Rackspace, OpenStack, CloudStack, vSphere…

Page 10: Vagrant & Docker

Customize

• config.vm.box* : Box information

• config.vm.network* : Network

• config.ssh* : SSH connection

• config.vm.synced_folder : Share folder

• config.vm.provider* : Custom provider settings

• config.vm.provision* : Provisioning (Puppet, Chef, Docker, Shell…)

Page 11: Vagrant & Docker

Provisioning?

• Automatically install software, alter configuration and more

• Shell Scripts

• File

• Puppet (Standalone & Agent)

• Chef (Solo & Client)

• Ansible

• Salt

• Docker!!!

Page 12: Vagrant & Docker

• Open-Source Container for Dummies

• Create lightweight, portable, self-sufficient container from any app.

• Build once… run anywhere

• Configure once… run anything

• Ecosystems! OS, VM’s, PaaS, IaaS…

• Base: LXC, OpenVZ, systemd-nspawn, libvirt-lxc, libvirt-sandbox, qemu/kvm, Jails, Solaris Zones, chroot (0.9*)

Page 13: Vagrant & Docker

Vagrant and Docker

• BOX = Machine

• Docker = Container (App package inside the Box)

• Functions: Pull, Build, Run

• Allow others provisioning (Shell, Puppet, Chef)

Page 14: Vagrant & Docker

Docker in Vagrantfile

Vagrant.configure("2") do |config|

v = config.vm

v.box = "precise64"

v.box_url = "http://bit.ly/1gLmNF0"

v.network "forwarded_port", guest: 8080, host: 9292

v.provision "docker", images: ["parana/web-xe-ubuntu"]

v.provision "docker" do |d|

d.run "parana/web-xe-ubuntu", args: "-p 9292:8080"

end

end

Page 15: Vagrant & Docker

Up!

$ vagrant up

Connect!

Page 16: Vagrant & Docker

YES !!

Page 17: Vagrant & Docker

Want to learn more?

• www.vagrantup.com

• www.docker.io

• GitHub docker

• Twitter @docker