Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit a5b148b

Browse files
authored
Merge pull request #1251 from gtardif/compose_health_display
Remove the HEALTH column in `docker compose ps`
2 parents 24d40ba + ad14069 commit a5b148b

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

cli/cmd/compose/ps.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ func runPs(ctx context.Context, opts psOptions) error {
9393
ports = append(ports, fmt.Sprintf("%s->%d/%s", p.URL, p.TargetPort, p.Protocol))
9494
}
9595
}
96-
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", container.Name, container.Service, container.State, container.Health, strings.Join(ports, ", "))
96+
status := container.State
97+
if container.Health != "" {
98+
status = fmt.Sprintf("%s (%s)", container.State, container.Health)
99+
}
100+
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", container.Name, container.Service, status, strings.Join(ports, ", "))
97101
}
98102
},
99-
"NAME", "SERVICE", "STATE", "HEALTH", "PORTS")
103+
"NAME", "SERVICE", "STATUS", "PORTS")
100104
}

local/e2e/compose/compose_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,15 @@ func TestLocalComposeUp(t *testing.T) {
8989

9090
})
9191

92-
t.Run("check healthcheck display", func(t *testing.T) {
92+
t.Run("check healthcheck output", func(t *testing.T) {
9393
c.WaitForCmdResult(c.NewDockerCmd("compose", "-p", projectName, "ps", "--format", "json"),
9494
StdoutContains(`"Name":"compose-e2e-demo_web_1","Project":"compose-e2e-demo","Service":"web","State":"running","Health":"healthy"`),
9595
5*time.Second, 1*time.Second)
96+
97+
res := c.RunDockerCmd("compose", "-p", projectName, "ps")
98+
res.Assert(t, icmd.Expected{Out: `NAME SERVICE STATUS PORTS`})
99+
res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_web_1 web running (healthy) 0.0.0.0:90->80/tcp`})
100+
res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_db_1 db running 5432/tcp`})
96101
})
97102

98103
t.Run("down", func(t *testing.T) {

local/e2e/compose/fixtures/sentences/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ services:
1313
- "my-label=test"
1414
healthcheck:
1515
test: ["CMD", "curl", "-f", "http://localhost:80/"]
16-
interval: 5s
16+
interval: 2s

0 commit comments

Comments
 (0)