Module: Tainers::API

Defined in:
lib/tainers/specification.rb

Overview

module Specification

Class Method Summary collapse

Class Method Details

.create(params) ⇒ Object



173
174
175
176
177
178
179
180
# File 'lib/tainers/specification.rb', line 173

def self.create params
  begin
    Docker::Container.create(params.dup)
    return true
  rescue Excon::Errors::Conflict
    return false
  end
end

.create_or_conflict(params) ⇒ Object



182
183
184
185
# File 'lib/tainers/specification.rb', line 182

def self.create_or_conflict params
  create params
  true
end

.get_by_name(name) ⇒ Object



165
166
167
168
169
170
171
# File 'lib/tainers/specification.rb', line 165

def self.get_by_name name
  begin
    Docker::Container.get(name)
  rescue Docker::Error::NotFoundError
    nil
  end
end

.image_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


153
154
155
156
157
158
159
# File 'lib/tainers/specification.rb', line 153

def self.image_exists? name
  begin
    return true if Docker::Image.get(name)
  rescue Docker::Error::NotFoundError
    return false
  end
end

.pull_image(name) ⇒ Object



161
162
163
# File 'lib/tainers/specification.rb', line 161

def self.pull_image name
  Docker::Image.create('fromImage' => name)
end