Boxes are the base images upon which Vagrant environments are built. So far in the book, we’ve been using a prebuilt box that has 64-bit Ubuntu 12.04 LTS installed. However, a box can contain any operating system installation, and new boxes can easily be created.
There are many reasons to create custom boxes. Primarily, you’ll want any box you use to match the same environment you’re running in production. So if you’re running the application you’re developing on FreeBSD in production, you’ll want FreeBSD in development as well.
Additionally, organizations with very complicated software dependencies that can sometimes take an hour or more to install will sometimes “prebake” their boxes with the software installed. For example, if your application relies on Java, instead of installing Java on every
vagrant up, you could install Java into the base image and already have it available. This saves precious time for creating the Vagrant environment.
Boxes can be created automatically from existing Vagrant environments, or manually from existing non-Vagrant managed VirtualBox virtual machines. In this chapter, we’ll cover both processes, as well as talk about what boxes are and how Vagrant manages them.
First, let’s discuss the rationale behind boxes. It is a fair question to ask why Vagrant doesn’t just install an operating system automatically.
Boxes are an optimization so that Vagrant doesn’t have to install a complete operating system on every
vagrant up. Installing ...