Class: Docker::Resource::Image

Inherits:
Base
  • Object
show all
Defined in:
lib/docker/resource/image.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Docker::Resource::Base

Instance Method Details

#history(name) ⇒ Object



19
20
21
22
23
# File 'lib/docker/resource/image.rb', line 19

def history(name)
  response = @connection.get("/images/#{name}/history")
  raise_if_image_not_found(response.status)
  response.body_as_json
end

#list(options = {}) ⇒ Object



8
9
10
# File 'lib/docker/resource/image.rb', line 8

def list(options = {})
  @connection.get('/images/json', options).body_as_json
end

#remove(name) ⇒ Object



34
35
36
37
38
# File 'lib/docker/resource/image.rb', line 34

def remove(name)
  status = @connection.delete("/images/#{name}").status
  raise_if_image_not_found(status)
  status == 204
end

#search(term) ⇒ Object



40
41
42
43
# File 'lib/docker/resource/image.rb', line 40

def search(term)
  params = {term: term}
  @connection.get("/images/search", params).body_as_json
end

#show(name) ⇒ Object

Inspect an image



13
14
15
16
17
# File 'lib/docker/resource/image.rb', line 13

def show(name)
  response = @connection.get("/images/#{name}/json")
  raise_if_image_not_found(response.status)
  response.body_as_json
end

#tag(name, repository, options = {}) ⇒ Object

Raises:

  • (BadParameterError)


26
27
28
29
30
31
32
# File 'lib/docker/resource/image.rb', line 26

def tag(name, repository, options = {})
  options = options.merge(repo: repository)
  status = @connection.post("/images/#{name}/tag", options).status
  raise_if_image_not_found(status)
  raise(BadParameterError) if status == 400
  status == 201
end