Browse code

Add an option to forward all ports to the vagrant host that have been exported from docker containers

Calen Pennington authored on 2013/06/08 04:56:39
Showing 1 changed files
... ...
@@ -5,6 +5,7 @@ BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
5 5
 BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
6 6
 AWS_REGION = ENV['AWS_REGION'] || "us-east-1"
7 7
 AWS_AMI    = ENV['AWS_AMI']    || "ami-d0f89fb9"
8
+FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS']
8 9
 
9 10
 Vagrant::Config.run do |config|
10 11
   # 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|
70 70
     config.vm.box_url = BOX_URI
71 71
   end
72 72
 end
73
+
74
+if !FORWARD_DOCKER_PORTS.nil?
75
+    Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config|
76
+        (49000..49900).each do |port|
77
+            config.vm.forward_port port, port
78
+        end
79
+    end
80
+
81
+    Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
82
+        (49000..49900).each do |port|
83
+            config.vm.network :forwarded_port, :host => port, :guest => port
84
+        end
85
+    end
86
+end