From charlesreid1

(Created page with "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 fr...")
 
 
Line 7: Line 7:
* Create the virtualbox image
* Create the virtualbox image
* Configure and set up the virtualbox image so it's ready to turn into a vagrant box
* 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


Now you can turn the virtualbox image into a vagrant box. Start by getting the name of the VirtualBox image you created (here, we'll assume it is <code>mycoolimage</code>:
==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 <code>mycoolimage</code>):


<pre>
<pre>
Line 20: Line 23:
mv package.box mycoolbox.box
mv package.box mycoolbox.box
</pre>
</pre>
==Add box to vagrant==


Now add the box to the list of boxes that are available to vagrant with the <code>vagrant box</code> command:
Now add the box to the list of boxes that are available to vagrant with the <code>vagrant box</code> command:
Line 25: Line 30:
<pre>
<pre>
vagrant box add mycoolbox mycoolbox.box
vagrant box add mycoolbox mycoolbox.box
</pre>


==Testing it out==
==Testing it out==
Line 36: Line 42:
vagrant ssh
vagrant ssh
</pre>
</pre>


=Flags=
=Flags=


{{VagrantFlag}}
{{VagrantFlag}}

Latest revision as of 01:02, 10 December 2019

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