Repository navigation
fix: pre_start hooks receive the service env_file and environment - #14293
Merged
Merged
Conversation
docker-agent
reviewed
Oct 7, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🔴 CRITICAL
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…vironment Reproduces docker#14287: a hook inheriting the service's env_file (or declaring its own) runs without those variables. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Picks up compose-spec/compose-go#938, which resolves the env_file entries of pre_start hooks like the service ones. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof
force-pushed
the
investigate-14287-pre-start-env
branch
from
October 12, 2026 15:31
0130978 to
0d300bc
Compare
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
This was referenced Nov 10, 2026
Closed
tmatens
added a commit
to tmatens/compose-lint
that referenced
this pull request
Nov 10, 2026
Compose 5.7.0 applies env files to pre_start hooks (docker/compose#14293): a hook receives its service's env_file values, then its own, and environment: still wins over every file. ADR-040 §7 had recorded a hook's env_file as inert on 5.6.1, and its premise check failed on the 5.7.0 bump as planned. Read a hook's own env_file targets as a service's are, and grade the keys whose value the hook deploys and its service does not. A value that reaches the hook unchanged stays the service's finding. The premise check now expects inert below 5.7 and applied from 5.7, measured on both. Closes #1220. Signed-off-by: Todd <tmatens@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does, in one sentence
A
pre_starthook now runs with the variables coming from theenv_fileentries it inherits from the service or declares itself.Context
A hook is a full container specification that inherits the service's attributes and completes them with its own. For
environmentandenv_filethat is a merge, not a replacement. In practice theenv_fileentries were never read for hooks: a service usingenv_file: .envran itspre_startcommand without any of those variables, whiledocker compose configshowed anenv_fileon the hook and noenvironment(#14287). Services that carried their variables inline were not affected, which is why this went unnoticed.What the PR brings
An e2e scenario locking the expected behavior: a hook that declares nothing sees the service's
env_fileandenvironment, and a hook that declares its ownenv_file/environmentsees both, its own values winning on conflicts. Each hook asserts the variables it must receive and fails theupotherwise.The fix itself lives in compose-go (compose-spec/compose-go#938, merged), which resolves hook environments exactly like service ones. Compose needs no code change beyond picking it up: the compose-go dependency is bumped to that commit, which is not part of a release yet.
Fixes #14287
🤖 Generated with Claude Code