From 302660e362ba36f9966b9a70b7d7284b94afb89d Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 7 Jun 2013 15:56:39 -0400 Subject: [PATCH] Add an option to forward all ports to the vagrant host that have been exported from docker containers --- Vagrantfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Vagrantfile b/Vagrantfile index 3d568266af..1688bd5211 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,6 +5,7 @@ BOX_NAME = ENV['BOX_NAME'] || "ubuntu" BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box" AWS_REGION = ENV['AWS_REGION'] || "us-east-1" AWS_AMI = ENV['AWS_AMI'] || "ami-d0f89fb9" +FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS'] Vagrant::Config.run do |config| # Setup virtual machine box. This VM configuration code is always executed. @@ -70,3 +71,17 @@ Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| config.vm.box_url = BOX_URI end end + +if !FORWARD_DOCKER_PORTS.nil? + Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config| + (49000..49900).each do |port| + config.vm.forward_port port, port + end + end + + Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| + (49000..49900).each do |port| + config.vm.network :forwarded_port, :host => port, :guest => port + end + end +end