Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to clone a vagrant box that is already installed

I must have the same VM in other computers but I don't want to download the whole box, php mysql, etc...

I have a box already configured the way it should be and I want to run this VM in others computers.

When the user run "vagrant up" the machine should start without downloading nothing.

Does anybody have a solution for that?

like image 890
Mateusgf Avatar asked Sep 30 '13 12:09

Mateusgf


People also ask

Can I have more than 1 vagrant box?

You can definitely run multiple Vagrant boxes concurrently, as long as their configuration does not clash with one another in some breaking way, e.g. mapping the same network ports on the host, or using same box names/IDs inside the same provider.


2 Answers

The easiest thing to do would be to package the pre-configured vagrant box and transfer the .box file to the other machine, add the box and run vagrant up.

So the steps look like below:

  1. Package the pre-configured box => vagrant package --base preconfigured_vm --output /path/to/mybox.box. Note that as per the docs, the --base option should be the UUID of the machine, or the name VirtualBox gives the machine (found when opening the VirtualBox application).
  2. transfer the box to the computer by using scp, rsync or whatever... (you also start a web server quickly by using python -m http.server PORT or ruby -run -e httpd /path/to -p PORT)
  3. Init and start vagrant init preconfigured_vm /path/to/mybox.box
  4. Done
like image 94
Terry Wang Avatar answered Oct 11 '22 23:10

Terry Wang


You just have to download the VM box only one time and make the all changes and configurations that you need and then re-package this one on a new box called "myVM.box".

Then you comment in the Vagrantfile the following line

#config.vm.box_url = "https://site_of_boxes..." 

and used

config.vm.box = "myVM" 

It starts up without download any VM.

like image 22
Robert Avatar answered Oct 12 '22 00:10

Robert