Add Health attribute on the docker ps command

Signed-off-by: Muhammad Daffa Dinaya <muhammaddaffadinaya@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Muhammad Daffa Dinaya
2025-07-16 13:20:45 +00:00
committed by Sebastiaan van Stijn
parent 81caabae43
commit 6e7a2c830d
9 changed files with 133 additions and 0 deletions

View File

@@ -296,9 +296,17 @@ func (v *View) GetAllNames() map[string][]string {
// A lock on the Container is not held because these are immutable deep copies.
func (v *View) transform(ctr *Container) *Snapshot {
health := container.NoHealthcheck
failingStreak := 0
if ctr.Health != nil {
health = ctr.Health.Status()
failingStreak = ctr.Health.FailingStreak
}
healthSummary := &container.HealthSummary{
Status: health,
FailingStreak: failingStreak,
}
snapshot := &Snapshot{
Summary: container.Summary{
ID: ctr.ID,
@@ -308,6 +316,7 @@ func (v *View) transform(ctr *Container) *Snapshot {
Mounts: ctr.GetMountPoints(),
State: ctr.State.StateString(),
Status: ctr.State.String(),
Health: healthSummary,
Created: ctr.Created.Unix(),
},
CreatedAt: ctr.Created,