From e455630867ab72a9db7670cd43cd70c708a274df Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Tue, 10 Feb 2015 14:02:18 -0700 Subject: [PATCH] Add initial version of Vagrant-Docker files Add Vagrantfiles and supporting documentation for running Docker under Vagrant. --- vagrant-docker/README.md | 14 ++++++++++++++ vagrant-docker/Vagrantfile | 34 +++++++++++++++++++++++++++++++++ vagrant-docker/host/Vagrantfile | 27 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 vagrant-docker/README.md create mode 100644 vagrant-docker/Vagrantfile create mode 100644 vagrant-docker/host/Vagrantfile diff --git a/vagrant-docker/README.md b/vagrant-docker/README.md new file mode 100644 index 0000000..b65328b --- /dev/null +++ b/vagrant-docker/README.md @@ -0,0 +1,14 @@ +# Running Docker in Vagrant + +These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) to quickly and relatively easily launch one or more Docker ([http://www.docker.com](http://www.docker.com)) containers. The configuration was tested using Vagrant 1.7.2, VMware Fusion 6.0.5, and the Vagrant VMware plugin. + +## Contents + +* **README.md**: The file you're currently reading. + +* **host/Vagrantfile**: This file is used by Vagrant to spin up a "host VM" for use with the Vagrant Docker provider. Edit this file to change the Vagrant box you'd like to use; by default, this Vagrantfile uses the "slowe/ubuntu-trusty-x64" box (built for the "vmware_desktop" provider). + +* **Vagrantfile**: This file is used by Vagrant to spin up the Docker containers on the host VM created by `host/Vagrantfile`. Edit this file to change any of the properties of the Docker container you want created by Vagrant. + +## Instructions + diff --git a/vagrant-docker/Vagrantfile b/vagrant-docker/Vagrantfile new file mode 100644 index 0000000..541dcda --- /dev/null +++ b/vagrant-docker/Vagrantfile @@ -0,0 +1,34 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Specify Vagrant version and Vagrant API version +Vagrant.require_version ">= 1.6.0" +VAGRANTFILE_API_VERSION = "2" +ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker' + +# Create and configure the Docker container(s) +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + # Disable synced folders for the Docker container + # (prevents an NFS error on "vagrant up") + config.vm.synced_folder ".", "/vagrant", disabled: true + + # Configure the Docker provider for Vagrant + config.vm.provider "docker" do |docker| + + # Define the location of the Vagrantfile for the host VM + # Comment out this line to use default host VM that is + # based on boot2docker + docker.vagrant_vagrantfile = "host/Vagrantfile" + + # Specify the Docker image to use + docker.image = "nginx" + + # Specify port mappings + # If omitted, no ports are mapped! + docker.ports = ['80:80', '443:443'] + + # Specify a friendly name for the Docker container + docker.name = 'nginx-container' + end +end diff --git a/vagrant-docker/host/Vagrantfile b/vagrant-docker/host/Vagrantfile new file mode 100644 index 0000000..967b9bb --- /dev/null +++ b/vagrant-docker/host/Vagrantfile @@ -0,0 +1,27 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Specify Vagrant version and Vagrant API version +Vagrant.require_version ">= 1.6.0" +VAGRANTFILE_API_VERSION = "2" + +# Create and configure the VM(s) +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + # Assign a friendly name to this host VM + config.vm.hostname = "docker-host" + + # Skip checking for an updated Vagrant box + config.vm.box_check_update = false + + # Always use Vagrant's default insecure key + config.ssh.insert_key = false + + # Spin up a "host box" for use with the Docker provider + # and then provision it with Docker + config.vm.box = "slowe/ubuntu-trusty-x64" + config.vm.provision "docker" + + # Disable synced folders (prevents an NFS error on "vagrant up") + config.vm.synced_folder ".", "/vagrant", disabled: true +end