A vagrant box is not the same as a vagrant project. Remember that a box is just an image of the operating system. You can create many projects using the same image. But we will need a box before we can create project.
You can use the precise32 box we downloaded earlier for multiple projects. This is actually one of the main use cases for vagrant. You can isolate the libraries and configurations of your projects. That way, you always have a clean baseline box.
To create our first project, we need to do (a) create a folder for our
project (b) run vagrant init
inside the project folder and (c) edit
the vagrant file if we want to alter some of the default settings of
vagrant
Creating a project.
mkdir ~/vms/myproject && cd ~/vms/myproject vagrant init precise32
This will create a file aptly named |
Start the vagrant project, we need to (a) switch to the vagrant project folder and (b) start the VM with the vagrant up command
Starting a vagrant project.
cd ~/vms/myproject && vagrant up
![]() | Tip |
---|---|
If you are used to working with virtualbox and any other hypervisor, you might be wondering why we don’t see the usual window of virtualbox. Vagrant, by default runs in headless mode that is why we don’t see any GUI interfaces to it. You can work with the virtualbox GUI if you really want (need) to, but working on the CLI is the idiomatic way of working with vagrant. |
Managing vagrant boxes.
vagrant suspendvagrant resume
vagrant halt
vagrant destroy
Puts the machine to sleep mode | |
Wake up from suspend | |
Graceful shutdown | |
This is like |
![]() | Turning the GUI on |
---|---|
If you still want to see the GUI of the virtualbox session, you can do the following
|