Class: Docker::Stack::Container
- Inherits:
-
Object
- Object
- Docker::Stack::Container
- Includes:
- ActionView::Helpers::DateHelper
- Defined in:
- lib/docker/stack/container.rb
Instance Method Summary collapse
-
#initialize(id) ⇒ Container
constructor
A new instance of Container.
- #service ⇒ Object
- #started ⇒ Object
- #status ⇒ Object
- #to_h ⇒ Object
- #uptime_in_words ⇒ Object
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
#service ⇒ Object
13 14 15 |
# File 'lib/docker/stack/container.rb', line 13 def service info('Config', 'Labels', 'com.docker.compose.service') end |
#started ⇒ Object
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 |
#status ⇒ Object
17 18 19 |
# File 'lib/docker/stack/container.rb', line 17 def status info('State', 'Health', 'Status') end |
#to_h ⇒ Object
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_words ⇒ Object
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 |