Class: Baleen::Container::DockerClient
- Inherits:
-
Object
- Object
- Baleen::Container::DockerClient
- Defined in:
- lib/baleen/container.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #create_container(params) ⇒ Object
-
#initialize(containers) ⇒ DockerClient
constructor
A new instance of DockerClient.
- #kill_all ⇒ Object
- #result ⇒ Object
- #start_container ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(containers) ⇒ DockerClient
7 8 9 |
# File 'lib/baleen/container.rb', line 7 def initialize(containers) @containers = containers end |
Instance Method Details
#create_container(params) ⇒ Object
11 12 13 |
# File 'lib/baleen/container.rb', line 11 def create_container(params) @container = @containers.create([params.shell, params.opt, params.commands], params.image) end |
#kill_all ⇒ Object
36 37 38 39 40 |
# File 'lib/baleen/container.rb', line 36 def kill_all @containers.list.each do |container| @containers.kill(container["Id"]) end end |
#result ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/baleen/container.rb', line 24 def result id = @container["Id"] rst = @containers.show(id) log = @containers.logs(id) Result.new( rst["State"]["ExitCode"], rst["ID"], log ) end |
#start_container ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/baleen/container.rb', line 15 def start_container id = @container["Id"] info "Start container #{id}" @containers.start(id) @containers.wait(id) info "Finish container #{id}" end |
#status ⇒ Object
42 43 44 |
# File 'lib/baleen/container.rb', line 42 def status info @containers.list end |