author thumb

Software Developer

Setting up a pre-configured box image in vagrant

Vagrant is awesome to control environments for differents applications. You can have one specific operacional system for each app, if you want to !

In this post i’ll show you how to download pre-configured box images and load it in few steps.

To get started you need to have Vagrant and Virtual Box instaled, of course.

Part 1: Packing your box

One awesome feature of vagrant is the possibility to pack and distribute your boxes in a very easy way.

Go to you vagrant file directory and run

vagrant package

This command will pack your entire box in a package.box file.

Part 2: Loading a packaged box

It’s very easy to load another box in your Vagrant. In your vagrantfile directory run the following command:

vagrant box add MyAwesomeMachine package.box virtualbox

when:

  • MyAwesomeMachine is the nickname of your new box.
  • package.box is a virtualbox image path that you packaged or downloaded.

After that you can use your new box. To make sure that is available you can run vagrant box list and this new box should show in list.

2) Now open your vagrantfile and change: config.vm.box = "precise32" to config.vm.box = "MyAwesomeMachine"

To get your machine up, run:

vagrant up

Bonus

In Virtual Box website has a lot of linux distributions images that you can load using this technique above. Check the list: http://virtualboxes.org/images/

Bonus 2 ( Rails Developers )

I’m leaving here a pre-configured Ubuntu 12.04 box that already have Rails 4, Ruby 2 and rbenv installed, all ready to run a rails app. You can download the image here https://mega.co.nz/#!Fsd0Tbrb!Ud68qgxpD9Av8VxdrVNPtCWciyh_DosXCopDWJksg4M

author thumb

Hugo Dias

Desenvolvedor Back-end & Front-end, Desenvolvimento Android e IOS, HTML5, CSS3 e JavaScript