Sha256: 43a56f30f6f559ce5b033c760d9ee2665044486c9736352d70a9a9347fc1b06e
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 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 guard_cmd_configured! 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: @provider_config.volumes, privileged: @provider_config.privileged } end def forwarded_ports @env[:forwarded_ports].map do |fp| # TODO: Support for the protocol argument "#{fp[:host]}:#{fp[:guest]}" end.compact end def guard_cmd_configured! if ! @provider_config.image raise Errors::ImageNotConfiguredError, name: @machine.name end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
docker-provider-0.1.0 | lib/docker-provider/action/create.rb |