Class: Conjure::Service::DockerShell
- Inherits:
-
Object
- Object
- Conjure::Service::DockerShell
- Defined in:
- lib/conjure/service/docker_shell.rb
Instance Attribute Summary collapse
-
#docker_host ⇒ Object
readonly
Returns the value of attribute docker_host.
Instance Method Summary collapse
- #command(*args, &block) ⇒ Object
- #default_image ⇒ Object
- #default_image_name ⇒ Object
- #image_options ⇒ Object
-
#initialize(options) ⇒ DockerShell
constructor
A new instance of DockerShell.
- #prepare(options) ⇒ Object
- #run(*args) ⇒ Object
- #stop(*args) ⇒ Object
Constructor Details
#initialize(options) ⇒ DockerShell
Returns a new instance of DockerShell.
6 7 8 9 |
# File 'lib/conjure/service/docker_shell.rb', line 6 def initialize() @docker_host = [:docker_host] @image = [:image] end |
Instance Attribute Details
#docker_host ⇒ Object (readonly)
Returns the value of attribute docker_host.
4 5 6 |
# File 'lib/conjure/service/docker_shell.rb', line 4 def docker_host @docker_host end |
Instance Method Details
#command(*args, &block) ⇒ Object
18 19 20 |
# File 'lib/conjure/service/docker_shell.rb', line 18 def command(*args, &block) (@image || default_image).command *args, &block end |
#default_image ⇒ Object
37 38 39 |
# File 'lib/conjure/service/docker_shell.rb', line 37 def default_image @default_image ||= @docker_host.images.create() end |
#default_image_name ⇒ Object
41 42 43 |
# File 'lib/conjure/service/docker_shell.rb', line 41 def default_image_name "ubuntu" end |
#image_options ⇒ Object
30 31 32 33 34 35 |
# File 'lib/conjure/service/docker_shell.rb', line 30 def { :base_image => (@image || default_image_name), :host_volumes => (@image.host_volumes if @image), } end |
#prepare(options) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/conjure/service/docker_shell.rb', line 11 def prepare() self.class.new( :docker_host => @docker_host, :image => @docker_host.images.create(.merge ), ) end |
#run(*args) ⇒ Object
22 23 24 |
# File 'lib/conjure/service/docker_shell.rb', line 22 def run(*args) (@image || default_image).run *args end |
#stop(*args) ⇒ Object
26 27 28 |
# File 'lib/conjure/service/docker_shell.rb', line 26 def stop(*args) (@image || default_image).stop *args end |