Class: EacDocker::Container
- Inherits:
-
Object
- Object
- EacDocker::Container
- Defined in:
- lib/eac_docker/container.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #hostname ⇒ Object
- #immutable_constructor_args ⇒ Object
- #immutable_volume ⇒ Object
- #on_detached ⇒ Object
- #run_command ⇒ Object
- #run_command_args ⇒ Object
- #stop ⇒ Object
- #volume(left_part, right_part = null) ⇒ Object
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/eac_docker/container.rb', line 11 def id @id end |
Instance Method Details
#hostname ⇒ Object
20 21 22 23 24 25 |
# File 'lib/eac_docker/container.rb', line 20 def hostname ::EacDocker::Executables.docker.command( 'inspect', '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}', id ).execute!.strip end |
#immutable_constructor_args ⇒ Object
14 15 16 |
# File 'lib/eac_docker/container.rb', line 14 def immutable_constructor_args [image] end |
#immutable_volume ⇒ Object
18 |
# File 'lib/eac_docker/container.rb', line 18 alias immutable_volume volume |
#on_detached ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/eac_docker/container.rb', line 27 def on_detached command = ::EacDocker::Executables.docker.command(*(%w[run --detach] + run_command_args)) self.id = command.execute!.strip begin yield(self) ensure stop end end |
#run_command ⇒ Object
41 42 43 |
# File 'lib/eac_docker/container.rb', line 41 def run_command ::EacDocker::Executables.docker.command('run', *run_command_args) end |
#run_command_args ⇒ Object
45 46 47 48 |
# File 'lib/eac_docker/container.rb', line 45 def run_command_args run_command_boolean_args + run_command_capabilities_args + run_command_envs_args + run_command_volumes_args + [image.provide.id] + command_args end |
#stop ⇒ Object
50 51 52 |
# File 'lib/eac_docker/container.rb', line 50 def stop ::EacDocker::Executables.docker.command('stop', id).execute! end |
#volume(left_part, right_part = null) ⇒ Object
37 38 39 |
# File 'lib/eac_docker/container.rb', line 37 def volume(left_part, right_part = null) immutable_volume(right_part.if_present(left_part) { |v| "#{left_part}:#{v}" }) end |