Configurable Ubuntu 18.04 VM using Vagrant
This article describes the steps to deploy a basic Ubuntu 18.04 on your host.
Prerequisite
Virtualbox. (Can be downloaded from this page Download Virtualbox)
Vagrant. (Can be downloaded from this page Download Vagrant)
Prepare a dir for your VM
Open a terminal and go to the dir 'vagrant_home' created during the installation of Vagrant.
Create a dir, for example 'basic1804vm'
Put the following Vagrantfile in that directory.
Vagrantfile |
---|
Vagrant.configure("2") do |config| |
This file will create an Ubuntu VM and configure in with 4GB om memory and 2 cpus.
Change the setting if needed for the purpose. However, be careful not to allocate to much of the host resources.
The shared folder is optional, replace with "." for current dir if used.
Further config is possible, see Vagrant docs
Start the VM and login
In the dir created above, do
vagrant up #Starts the VM
vagrant ssh #Log in to VM
done! You now have the terminal to the VM running.
The VM is now visible in the Virtualbox GUI and is ready to be used.
If more terminals are needed to the same vm, open a new terminal window and go to the same dir and do 'vagrant ssh'
Remote the VM
Logout ('exit' or 'logout') from the VM and do
vagrant destroy
After this the VM can be started again according to the previous section "Start the VM and login".
Install docker
In the VM terminal do
sudo apt-get update
sudo apt -y install docker docker-compose