Class: Docker::Inspect

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/inspect.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Inspect

Returns a new instance of Inspect.



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

def initialize(id)
  @id = id[0..11]
  @inspekt = JSON.load(`docker inspect #{@id}`).first
end

Instance Attribute Details

#inspektObject (readonly)

Returns the value of attribute inspekt.



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

def inspekt
  @inspekt
end

Instance Method Details

#envObject



16
17
18
19
20
21
# File 'lib/docker/inspect.rb', line 16

def env
  inspekt["Config"]["Env"].each_with_object({}) do |e,h| 
    pair = e.split('=') 
    h[pair.first] = pair.last
  end
end

#ip_addressObject



23
24
25
# File 'lib/docker/inspect.rb', line 23

def ip_address
  inspekt["NetworkSettings"]["IPAddress"]
end

#nameObject



12
13
14
# File 'lib/docker/inspect.rb', line 12

def name
  inspekt["Name"][1..-1]
end

#portsObject



27
28
29
# File 'lib/docker/inspect.rb', line 27

def ports
  inspekt["NetworkSettings"]["Ports"]
end

#stateObject



31
32
33
# File 'lib/docker/inspect.rb', line 31

def state 
  inspekt["State"]
end

#to_sObject



35
36
37
# File 'lib/docker/inspect.rb', line 35

def to_s
  inspekt.to_s
end