Tools needed?

  • Terminal
  • Editor
  • Virtualbox
  • Vagrant

How we do it?


  • Check that vagrant already installed

    $ vagrant --version
    

  • Initiate

    $ vagrant init
    

    This command will generate Vagrantfile


  • Configure the Vagrantfile

    Vagrant.configure("2") do |config|
      # define
      config.vm.define "playground-ubuntu" do |ubuntu|
        ubuntu.vm.box = "ubuntu/bionic64" # image
        ubuntu.vm.hostname = "dadossae" # hostname
    
        ubuntu.vm.provider "virtualbox" do |vb|
          vb.gui = false
          vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] # fast http
          vb.customize ["modifyvm", :id, "--memory", 1024] # ram
          vb.customize ["modifyvm", :id, "--name", "playground-ubuntu18"] # name of virtualbox
        end
      end
    end
    

  • Launch VM

    $ vagrant up
    

    VM will up on VirtualBox


  • SSH into VM

    $ vagrant ssh
    

    or this command

    $ vagrant ssh playground-ubuntu
    

  • Stop the VM

    $ vagrant halt
    

    or this command

    $ vagrant halt playground-ubuntu
    

  • Destroy the VM

    $ vagrant destroy
    

    or this command

    $ vagrant destroy playground-ubuntu
    

References