Customizing a vagrant box
- Qasim Zee
- Mar 30, 2015
- 1 min read
Recently, I got to know an excellent ready virtual machines solution known as Vagrant. The solution I was looking for was that I can create a custom virtual machine and install my development environment on that e.g. LAMP or MEAN so that new developers can easily download that machine and can start work on that straight away.
If we follow default vagrant instructions, we will end up having and Ubuntu virtual machine. My target was to have a Centos 7 machine with Apache, PHP and MySQL.
So I installed a basic Centos 7 virtual machine, the instructions are available on http://docs.vagrantup.com/v2/getting-started/boxes.html. Instead of “hashicorp/precise32”, I choose serveit/centos-7. After adding the box, I installed the required tools, now my machine is ready so it’s time to export my VM as a vagrant box, it is so simple:
We can package a box using command:
Shell
1
vagrant
package
--
output
custom_lamp
.box
That’s it, the above command will will create a VM for virtual box. Now you can delete the existing box using:
Shell
1
vagrant
destroy
Delete the Vagrantfile and can use this new box with the following command:
Shell
1
vagrant
box
add
custom_lamp
.box
You can add your distribution to vagrant repo if you want.
Commentaires