Support extra_hosts on pre_start#13940
Open
ArtuoS wants to merge 1 commit into
Open
Conversation
Signed-off-by: ArtuoS <arthureduardomolinari@gmail.com>
ArtuoS
force-pushed
the
13939-support-extra-hosts
branch
from
July 14, 2026 15:45
fa88625 to
98a7a13
Compare
Contributor
|
This assumes we want the pre_start to inherit config from service, which must be debated (what should be inherited? What should not? How to override?) |
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 I did
Fixes #13939.
pre_start hooks run as ephemeral containers with their own
HostConfig, but the configuration was built with only four fields (AutoRemove,Privileged,VolumesFrom,NetworkMode), omittingExtraHostsentirely. This meant custom host mappings defined on the service were invisible inside pre_start containers, even though they were correctly applied to the main service containers.This PR propagates
service.ExtraHostsinto the pre_start container'sHostConfig, matching the behavior of regular containers created viagetCreateConfigs().pkg/compose/pre_start.go—createPreStartContainerExtraHosts: service.ExtraHosts.AsList(":")on the hook container'sHostConfigpkg/compose/pre_start_test.goTestPreStart_ExtraHostsPassedToContainerverifying the host mapping is forwardedScope
Only
ExtraHostsis in scope. OtherHostConfigfields (e.g.DNS,CapAdd,SecurityOpt) are not propagated to pre_start containers and can be addressed separately if needed.How to test manually