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.



8
9
10
11
# File 'lib/docker/stack/container.rb', line 8

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

Instance Method Details

#serviceObject



13
14
15
# File 'lib/docker/stack/container.rb', line 13

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

#startedObject



21
22
23
24
25
# File 'lib/docker/stack/container.rb', line 21

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

#statusObject



17
18
19
# File 'lib/docker/stack/container.rb', line 17

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

#to_hObject



32
33
34
# File 'lib/docker/stack/container.rb', line 32

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

#uptime_in_wordsObject



27
28
29
30
# File 'lib/docker/stack/container.rb', line 27

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