Create Debian VM with Docker Host using Vagrant–automatically include Guest Additions image 107

Create Debian VM with Docker Host using Vagrant–automatically include Guest Additions

A short and simple article. I needed a Debian VM that I could use as Docker host – to run on my Windows 10 laptop. I resorted to Vagrant. With a few very simple steps, I got what I wanted:

0. install Vagrant (if not already done)

0. install Vagrant plugin for automatically adding Virtual Box Guest Additions to every VM stamped out by Vagrant (so folder mapping from host laptop to VM is supported)

image

1. create a fresh directory with a simple Vagrant file that refers for Debian image

2. run vagrant up

3. sit back and relax (few minutes)

4. use vagrant ssh to connect into the running VM and start doing stuff.

The vagrant file:

Vagrant.configure("2") do |config|
  
config.vm.provision "docker"

config.vm.define "debiandockerhostvm"
# https://app.vagrantup.com/debian/boxes/jessie64
config.vm.box = "debian/jessie64"
config.vm.network "private_network", ip: "192.168.188.105"
 

config.vm.synced_folder "./", "/vagrant", id: "vagrant-root",
       owner: "vagrant",
       group: "www-data",
       mount_options: ["dmode=775,fmode=664"],
       type: ""
         
config.vm.provider :virtualbox do |vb|
   vb.name = "debiananddockerhostvm"
   vb.memory = 4096
   vb.cpus = 2
   vb.customize ["modifyvm", :id, "--natdnshostresolver1","on"]
   vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
  
end

Running Vagrant to create and subsequently run the VM:

image

image

Use vagrant ssh to enter the Virtual Machine and start mucking around:

image

Resources

Vagrant Plugin for automatically installing Guest Addition to each VM that is produced: https://github.com/dotless-de/vagrant-vbguest/

Vagrant Box Jessie: https://app.vagrantup.com/debian/boxes/jessie64