Now that you have initialized your project and configured a box for it to use, it is time to boot your first Vagrant environment.
Run the following from your terminal:
$ vagrant up
In less than a minute, this command will finish and you will have a virtual machine running Ubuntu.
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:
$ vagrant ssh Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Tue Jun 16 21:57:57 UTC 2020 System load: 0.44 Processes: 91 Usage of /: 2.5% of 61.80GB Users logged in: 0 Memory usage: 11% IP address for eth0: 10.0.2.15 Swap usage: 0% * MicroK8s gets a native Windows installer and command-line integration. https://ubuntu.com/blog/microk8s-installers-windows-and-macos 0 packages can be updated. 0 updates are security updates. vagrant@vagrant:~$
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
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.
vagrant@vagrant:~$ logout Connection to 127.0.0.1 closed.
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
$ vagrant destroy default: Are you sure you want to destroy the 'default' VM? [y/N] y ==> default: Forcing shutdown of VM... ==> default: Destroying VM and associated drives...
vagrant destroy command does not remove the downloaded box
file. List your box files.
$ vagrant box list hashicorp/bionic64 (virtualbox, 1.0.282)
Remove the box file with the
remove subcommand, providing the name of your box.
$ vagrant box remove hashicorp/bionic64 Removing box 'hashicorp/bionic64' (v1.0.282) with provider 'virtualbox'...
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.