Class: Docker::Stack::Container

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
lib/docker/stack/container.rb

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Container

Returns a new instance of Container.



10
11
12
13
# File 'lib/docker/stack/container.rb', line 10

def initialize(id)
  @id = id
  @container = Docker::Container.get(id)
end

Instance Method Details

#serviceObject



15
16
17
# File 'lib/docker/stack/container.rb', line 15

def service
  info('Config', 'Labels', 'com.docker.compose.service')
end

#startedObject



23
24
25
26
27
# File 'lib/docker/stack/container.rb', line 23

def started
  value = info('State', 'StartedAt')
  return value if value == 'unknown'
  Time.parse(value).utc
end

#statusObject



19
20
21
# File 'lib/docker/stack/container.rb', line 19

def status
  info('State', 'Health', 'Status')
end

#to_hObject



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

def to_h
  { id: @id, service: service, status: status, started: started, running: uptime_in_words }
end

#uptime_in_wordsObject



29
30
31
32
# File 'lib/docker/stack/container.rb', line 29

def uptime_in_words
  return started if started == 'unknown'
  time_ago_in_words(started)
end