module Baleen module Container class DockerClient Result = Struct.new("Result", :status_code, :container_id, :log) def initialize(containers) @containers = containers end def create_container(params) @container = @containers.create([params.shell, params.opt, params.commands], params.image) end def start_container id = @container["Id"] info "Start container #{id}" @containers.start(id) @containers.wait(id) info "Finish container #{id}" end def result id = @container["Id"] rst = @containers.show(id) log = @containers.logs(id) Result.new( rst["State"]["ExitCode"], rst["ID"], log ) end def kill_all @containers.list.each do |container| @containers.kill(container["Id"]) end end def status info @containers.list end end end end