Skip to content

Instantly share code, notes, and snippets.

@btoone

btoone/Vagrantfile

Last active Aug 29, 2015
Embed
What would you like to do?
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
@btoone

This comment has been minimized.

Copy link
Owner Author

@btoone btoone commented Feb 8, 2015

After running vagrant up confirm the Docker install

docker -v
docker run -it ubuntu /bin/bash

Inspect Docker processes

docker ps -a
@btoone

This comment has been minimized.

Copy link
Owner Author

@btoone btoone commented Feb 8, 2015

Discovered that the $script is not necessary since the docker provisioner will install Docker for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.