btoone
2/8/2015 - 3:09 AM

Setup VM and Install Docker

Setup VM and Install Docker

# -*- mode: ruby -*-
# vi: set ft=ruby :

ENV['VAGRANT_DEFAULT_PROVIDER'] ||= 'virtualbox'

# Install Docker.io
# Adapted from https://docs.docker.com/installation/debian/
$script = <<SCRIPT
echo "[SCRIPT] Running as: `whoami`"

echo "\n[SCRIPT] Updating ..."
apt-get update

echo "\n[SCRIPT] Installing Docker.io"
apt-get install -y docker.io


echo "\n[SCRIPT] Modifying vagrant user groups"

# Add the docker group if it doesn't already exist.
groupadd docker

# Add the vagrant user to the docker group.
usermod -a -G docker vagrant


echo "\n[SCRIPT] Restarting Docker daemon"
service docker.io restart

exit 0
SCRIPT

Vagrant.configure(2) do |config|

  # Vagrant knows to look on Atlas to find this box if it is not already installed.
  # This box is Docker friendly but does not have docker installed. See 
  # https://github.com/phusion/open-vagrant-boxes for more detail.
  config.vm.box = "phusion/ubuntu-14.04-amd64"

  # Remember, shell provisioning is always ran as root
  # config.vm.provision "shell", inline: $script        <- Un-necessary since docker provisioner installs docker
  
  # The docker provisioner also installs docker to the vm
  config.vm.provision "docker",
    images: ["ubuntu"]
end