Boot an Environment
Now that you have initialized your project and configured a box for it to use, it is time to boot your first Vagrant environment.
Bring up a virtual machine
Run the following from your terminal:
In less than a minute, this command will finish and you will have a virtual machine running Ubuntu.
SSH into the machine
You will not actually see anything though, since Vagrant runs the virtual machine without a UI. To prove that it is running, you can SSH into the machine:
This command will drop you into a full-fledged SSH session. Go ahead and
interact with the machine and do whatever you want. Although it may be tempting,
be careful about rm -rf /
, since Vagrant shares a directory at /vagrant
with the directory on the host containing your Vagrantfile, and this can
delete all those files. Shared folders will be covered in the next section.
Take a moment to think what just happened: With just one line of configuration and one command in your terminal, we brought up a fully functional, SSH accessible virtual machine. Cool.
Terminate the SSH session with CTRL+D
, or by logging out.
Destroy the machine
Once you're back on your host machine, stop the machine that Vagrant is managing and remove all the resources created during the machine-creation process. When prompted, confirm with a yes
.
Remove the box
The vagrant destroy
command does not remove the downloaded box
file. List your box files.
Remove the box file with the remove
subcommand, providing the name of your box.
You have successfully created and interacted with your first Vagrant environment! Continue to the next tutorial to sync files between your local computer and the guest virtual machine.