Appendix C. Vagrant

 

At various points in this book we use virtual machines to demonstrate a technique for Docker that requires a full machine representation, or even multi-virtual-machine orchestration.

Vagrant offers a simple way to start, provision, and manage virtual machines from the command line, and it’s available on multiple platforms.

C.1. Setting up

Go to https://www.vagrantup.com and follow the instructions there to get set up.

C.2. GUIs

When running vagrant up to start up a virtual machine, Vagrant reads the local file called Vagrantfile to determine the settings.

A useful setting that you can create or change within the section for your provider is the gui one:

v.gui = true

For example, if your provider is VirtualBox, a typical config section might look like this:

config.vm.provider "virtualbox" do |v, override|
      override.vm.box     = vagrant_openshift_config['virtualbox']
      ['box_name'] unless dev_cluster
      override.vm.box_url = vagrant_openshift_config['virtualbox']
      ['box_url'] unless dev_cluster
      override.ssh.insert_key = vagrant_openshift_config['insert_key']

      v.memory            = vagrant_openshift_config['memory'].to_i
      v.cpus              = vagrant_openshift_config['cpus'].to_i

      v.customize ["modifyvm", :id,
      "--cpus", vagrant_openshift_config['cpus'].to_s]
      v.gui               = false
    end if vagrant_openshift_config['virtualbox']

C.3. Memory