From charlesreid1

This page covers how to create a virtual machine image that can be used with Vagrant (called a "vagrant box").

Vagrant Box from VirtualBox Image

To create a vagrant box from an existing virtualbox image:

  • Create the virtualbox image
  • Configure and set up the virtualbox image so it's ready to turn into a vagrant box
  • Turn the virtualbox image into a vagrant box

Vagrant package step

Once you've gotten your virtualbox image ready to go, make a note of its name. Then you can turn it into a vagrant box by running the command (assuming the virtualbox image name is mycoolimage):

# This base name should match the name in VirtualBox
vagrant package --base mycoolbox

This will create a file named package.box in the current directory. This can be renamed:

mv package.box mycoolbox.box

Add box to vagrant

Now add the box to the list of boxes that are available to vagrant with the vagrant box command:

vagrant box add mycoolbox mycoolbox.box

Testing it out

To test out the new vagrant box:

mkdir test && cd test
vagrant init mycoolbox
vagrant up
vagrant ssh

Flags