diff --git a/plugins/providers/docker/action.rb b/plugins/providers/docker/action.rb index 55001535e..2eee6dd0b 100644 --- a/plugins/providers/docker/action.rb +++ b/plugins/providers/docker/action.rb @@ -39,7 +39,6 @@ module VagrantPlugins b2.use SyncedFolderCleanup b2.use SyncedFolders b2.use PrepareNFSSettings - b2.use ForwardPorts # This will actually create and start, but that's fine b2.use Create b2.use action_boot @@ -224,7 +223,6 @@ module VagrantPlugins action_root = Pathname.new(File.expand_path("../action", __FILE__)) autoload :Create, action_root.join("create") autoload :Destroy, action_root.join("destroy") - autoload :ForwardPorts, action_root.join("forward_ports") autoload :HasSSH, action_root.join("has_ssh") autoload :HostMachine, action_root.join("host_machine") autoload :HostMachineRequired, action_root.join("host_machine_required") diff --git a/plugins/providers/docker/action/create.rb b/plugins/providers/docker/action/create.rb index a19aafd6a..b6e7fab9d 100644 --- a/plugins/providers/docker/action/create.rb +++ b/plugins/providers/docker/action/create.rb @@ -26,6 +26,9 @@ module VagrantPlugins params[:volumes].each do |volume| env[:ui].detail("Volume: #{volume}") end + params[:ports].each do |pair| + env[:ui].detail(" Port: #{pair}") + end cid = @driver.create(params) end @@ -54,7 +57,14 @@ module VagrantPlugins end def forwarded_ports - @env[:forwarded_ports].map do |fp| + mappings = {} + @machine.config.vm.networks.each do |type, options| + if type == :forwarded_port && options[:id] != 'ssh' + mappings[options[:host]] = options + end + end + + mappings.values.map do |fp| # TODO: Support for the protocol argument "#{fp[:host]}:#{fp[:guest]}" end.compact diff --git a/plugins/providers/docker/action/forward_ports.rb b/plugins/providers/docker/action/forward_ports.rb deleted file mode 100644 index 5051e7ab3..000000000 --- a/plugins/providers/docker/action/forward_ports.rb +++ /dev/null @@ -1,54 +0,0 @@ -module VagrantPlugins - module DockerProvider - module Action - class ForwardPorts - def initialize(app, env) - @app = app - end - - def call(env) - @env = env - - env[:forwarded_ports] = compile_forwarded_ports(env[:machine].config) - - if env[:forwarded_ports].any? - env[:ui].info I18n.t("vagrant.actions.vm.forward_ports.forwarding") - inform_forwarded_ports(env[:forwarded_ports]) - end - - # FIXME: Check whether the container has already been created with - # different exposed ports and let the user know about it - - @app.call env - end - - def inform_forwarded_ports(ports) - ports.each do |fp| - message_attributes = { - :adapter => 'eth0', - :guest_port => fp[:guest], - :host_port => fp[:host] - } - - @env[:ui].info(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry", - message_attributes)) - end - end - - private - - def compile_forwarded_ports(config) - mappings = {} - - config.vm.networks.each do |type, options| - if type == :forwarded_port && options[:id] != 'ssh' - mappings[options[:host]] = options - end - end - - mappings.values - end - end - end - end -end