Developing with Virtual Machines

Using virtual machines for development provides a number of advantages over setting up environments directly on your laptop or desktop. I’m running CentOS 6.3 in VirtualBox, and I’m going to give you three reasons why I prefer developing this way.

Security Blanket

Virtual Box lets you take snapshots of your VM at any time, even when it’s running. I usually use this feature when I’ve gotten some weird configuration working, or I’ve done system updates. This gives me the ability to go back to a known good state if something goes wrong. I will also take a snapshot of my system before I try a potentially risky spike or upgrade. That way if things don’t go as planned, I simply revert to the snapshot I took when everything was working – no reinstalls or reconfiguration are necessary.

System Portability

There’s a feature in Virtual Box called Export Appliance. This creates an industry standard disk image that most virtual managers can import. I like to think of snapshots as an incremental backup and appliances as a full backup. I’ll install an OS, run the updates, install the tools I need, and make any configuration changes (taking snapshots along the way!). Once everything is ready, I can create the appliance and send it to others so they can import it into their virtual manager and have a development-ready OS up and running in under 5 minutes.

One Host, Many Guests

The physical machine you have is your host (your laptop or desktop) and the VMs that you have on your system are the guests. You can have as many different guests as your hard drive space will allow. You might do this if you like CentOS for PHP and Ubuntu for Rails (or vice-versa). You might also do this if you wanted to have a separate VM for each of your clients (which is really easy when all you have to do is import the appliance again). This ensures you don’t mess up one client’s environment while you’re upgrading something for another.

There are a few drawbacks to running VMs for developing, but the ones I’ve come across are pretty insignificant compared to the benefits mentioned above. In my next post, I’ll describe how we got around our main problem with running VMs on a laptop: memory.

Leave a Reply

Your email address will not be published. Required fields are marked *

A less annoying captcha to prove you're a person