Class: Docker::Image

Inherits:
Object
  • Object
show all
Extended by:
Equality, Helpers
Defined in:
lib/docker/image.rb

Direct Known Subclasses

Repository

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

rails_image, rails_server

Methods included from Equality

==

Constructor Details

#initialize(id) ⇒ Image

Returns a new instance of Image.



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

def initialize(id)
  @id = id[0..11]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/docker/image.rb', line 6

def id
  @id
end

Class Method Details

.build(path, name) ⇒ Object



11
12
13
14
15
16
# File 'lib/docker/image.rb', line 11

def self.build(path, name)
  name = "#{Docker::USER_NAME}/#{name}" 
  repo, tag = name.split(':')
  id = `docker build -t #{name} #{path}`[-13..-2]
  tag ? Tag.new(repo, tag) : Repository.new(id, repo)
end

Instance Method Details

#image_idObject



26
27
28
# File 'lib/docker/image.rb', line 26

def image_id
  id
end

#inspektObject



22
23
24
# File 'lib/docker/image.rb', line 22

def inspekt
  Docker.inspekt(id)
end

#remove!Object



18
19
20
# File 'lib/docker/image.rb', line 18

def remove!
  `docker rmi #{id}`
end

#repositoriesObject



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

def repositories 
  Docker.images.select { |repo| repo == self }
end

#to_sObject



30
31
32
# File 'lib/docker/image.rb', line 30

def to_s
  id
end