Skip to content

feat(up): report the health check output when a container is unhealthy - #14586

Open
htoyoda18 wants to merge 1 commit into
docker:mainfrom
htoyoda18:fix/health-check-output-on-unhealthy
Open

htoyoda18 wants to merge 1 commit into
docker:mainfrom
htoyoda18:fix/health-check-output-on-unhealthy

Conversation

@htoyoda18

@htoyoda18 htoyoda18 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

When up --wait or a service_healthy dependency fails on an unhealthy container, the error now includes the exit code and output of the last health check, instead of only container X is unhealthy. That output is only stored in the container's health state (it never reaches the container logs), so until now finding out why a service was unhealthy required a docker inspect.

Related issue

Fixes #14585

Changes made

  • pkg/compose/dependency_wait.go: isServiceHealthy builds the unhealthy error with a new unhealthyError, which reads the last entry of State.Health.Log from the inspect result already fetched (no extra API call). The output is trimmed with the existing outputTail and the same limits as a failing hook's output (fix(hooks): include hook output in the error when a hook fails #14088): last 10 lines, 2 KiB. If the probe never completed (exit code -1, e.g. a timeout), the daemon writes the reason in the output, so only the output is shown. With no health log, the message stays as it was.
  • pkg/compose/dependency_wait_test.go: three new cases in TestIsServiceHealthyStatuses: the last probe is reported (not an older one), a probe with no output, and a probe that did not complete.
  • internal/e2e/compose_up_test.go + testdata/TestUpWaitReportsHealthCheckOutput/: a scenario where up -d --wait must fail with the probe's exit code and output in the error.

Testing done

  • Unit tests pass: make test
  • E2E tests pass: make e2e-compose or make e2e-compose-standalone
  • Linting passes: make lint
  • Code formatted: make fmt
  • Manually tested (describe):

Additional context

(not mandatory) A picture of a cute animal, if possible in relation to what you did

image

Signed-off-by: Hiroto Toyoda <hirototoyoda20020927@gmail.com>
@htoyoda18
htoyoda18 marked this pull request as ready for review December 4, 2026 14:24
@htoyoda18
htoyoda18 requested review from a team as code owners December 4, 2026 14:24
@htoyoda18
htoyoda18 requested review from glours and ndeloof December 4, 2026 14:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show the health check output when up --wait or service_healthy fails on an unhealthy container

1 participant