Introduction
Creating a new Vagrant base box from an existing VM
Vagrant

Creating a new Vagrant base box from an existing VM

Citation Copied

Typically my Vagrant workflow starts with a official base box provided by Ubuntu. With help of a Vagrant providervagrant up will create a virtual machine (VM) using specified base box.

Then using either Puppet provisioner or apt-get I normally install/update required packages and libraries in my VM.

Once install/update is finished, sometime I prefer to repackage updated virtual machine as a new base box to avoid repeating the install and update process. Also repackaging allows me to work offline as no provisioning is required.

First step is to get id or specific name of VM from your Vagrant provider. If you are using VirtualBox as provider you can see a list of virtual machine with their specific machine. For example following image illustrate two VM running under VirtualBox Node_default_1387087098 and Blogs_default_1386384681

Get VM List from VirtualBox

Once you have specific name for VM which you want to repackage, you can run

vagrant package --base SPECIFIC_NAME_FOR_VM --output /yourfolder/OUTPUT_BOX_NAME.box

So for instance, if I am interested to repackage VM Node_default_1387087098 then I will run,

vagrant package --base Node_default_1387087098 --output /myfolder/precise64Node.box

Packaging VM as new base box

Please note I named output box as precise64Node as original base box is precise64 and I repackaged for Node specific uses. It is just a personal convention.

Now you can use this new base box like any other Vagrant box.

Using new base box

Abhishek Tiwari
Author

Abhishek Tiwari

Tech Savant, Servant Leader

View Comments
Next Post

Responsive Image Distilled

Previous Post

Decoupling Deployment and Release- Feature Toggles

Subscribe to Abhishek Tiwari

Subscribe to our newsletter and receive access to exclusive posts and content updates. We don't spam and your email won't be shared with third-parties.

Thanks for subscribing!

Check your inbox to confirm your subscription.

Please enter a valid email address!