Sha256: 86675980af186087e4c0ae4295b17c15da4ab72641c8a818c147612442148f64
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module VagrantPlugins module DockerProvider module Action class Create def initialize(app, env) @app = app @@mutex ||= Mutex.new end def call(env) @env = env @machine = env[:machine] @provider_config = @machine.provider_config @machine_config = @machine.config @driver = @machine.provider.driver cid = '' @@mutex.synchronize do cid = @driver.create(create_params) end @machine.id = cid @app.call(env) end def create_params container_name = "#{@env[:root_path].basename.to_s}_#{@machine.name}" container_name.gsub!(/[^-a-z0-9_]/i, "") container_name << "_#{Time.now.to_i}" { image: @provider_config.image, cmd: @provider_config.cmd, ports: forwarded_ports, name: container_name, hostname: @machine_config.vm.hostname, volumes: synced_folders } end def forwarded_ports @env[:forwarded_ports].map do |fp| # TODO: Support for the protocol argument "#{fp[:host]}:#{fp[:guest]}" end.compact end def synced_folders @env[:synced_folders].map do |sf| "#{sf[:hostpath]}:#{sf[:guestpath]}" end.compact end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
docker-provider-0.0.2 | lib/docker-provider/action/create.rb |
docker-provider-0.0.1 | lib/docker-provider/action/create.rb |