Class: Ruboty::Docker::Actions::Run
- Defined in:
- lib/ruboty/docker/actions/run.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Ruboty::Docker::Actions::Base
Instance Method Details
#call ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruboty/docker/actions/run.rb', line 5 def call image_name = [:image_name] args = [:args].gsub(/\"/) { $1 }.split('-') args.each do |a| if /^v/ === a set_volumes(a) elsif /^e/ === a set_env(a) elsif /^link/ === a set_link(a) elsif /^net/ === a set_net(a) else set_command(a) end end image = ::Docker::Container.create('Image' => image_name, 'Binds' => @volume, 'Env' => @env, 'Cmd' => @command) .reply("Start running the #{image_name}...") ::Thread.new { image.tap(&:start).attach do |stream, chunk| .reply stream .reply chunk end } rescue => e value = [e.class.name, e., e.backtrace].join("\n") .reply value ensure end |