Skip to content

fix(pre_start): name the hook when its container cannot start - #14520

Merged
glours merged 1 commit into
docker:mainfrom
ndeloof:fix-pre-start-hook-start-error
Nov 17, 2026
Merged

glours merged 1 commit into
docker:mainfrom
ndeloof:fix-pre-start-hook-start-error

Conversation

@ndeloof

@ndeloof ndeloof commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

What this PR does, in one sentence

Names the pre_start hook, and its image, in the error reported when the hook container cannot start.

Context

A pre_start hook is the service container with only the attributes it declares replaced, so it inherits the service's entrypoint even when the hook sets another image (#14513). When that executable does not exist in the image of the hook, the engine refuses to start the hook container, and up fails with the bare engine error (exec: "/bin/busybox": stat /bin/busybox: no such file or directory). It names neither the hook nor its image, and it surfaces on the row of the service container (Container app-1 Starting → Error), so it reads as the service failing to start and sends the user looking in the wrong place.

What the PR brings

The error now reads service "app" pre_start[0] (image hello-world): failed to start the hook container: <engine error>, in the same form as the other pre_start errors, both on the progress row and in the final error. The engine error is wrapped, so errors.Is and errors.As still see it.

The inheritance itself is unchanged: it follows the spec, and entrypoint: [] or entrypoint: null on the hook opts out of it.

Addresses #14513 (the error message part; the inheritance is how the spec defines pre_start).

🤖 Generated with Claude Code

A pre_start hook container that fails to start (an executable missing from
the image of the hook, a bad mount, ...) was reported with the bare error of
the engine. It names neither the hook nor its image, and it surfaces on the row
of the service container, so it reads as the service failing to start.

Wrap it with the service, the index of the hook and its image, like the other
pre_start errors: service "app" pre_start[0] (image hello-world): failed to
start the hook container: <engine error>. The wrapped error is unchanged for
errors.Is and errors.As.

Refs docker#14513

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof
ndeloof requested review from a team as code owners November 17, 2026 07:38
@ndeloof
ndeloof requested a review from glours November 17, 2026 07:38

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

Lower-confidence findings (not posted inline)

  • [low] pkg/compose/pre_start.go:272 — hookImageSuffix returns empty string when hook inherits the service image (Image == ""), so the error message omits the image name in the most common case; consider threading the resolved image name through to the caller (confidence: not scored — low severity, not verified)

@ndeloof
ndeloof requested a review from docker-agent November 17, 2026 07:45
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/compose/pre_start.go 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@glours glours left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glours
glours merged commit 0e00056 into docker:main Nov 17, 2026
64 of 65 checks passed
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.

3 participants