Repository navigation
Conversation
…o bake Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
|
@ndeloof Thanks for the review! Could you approve the CI workflows when you have a moment? |
agammann
left a comment
There was a problem hiding this comment.
[P1] Preserve an explicit named context when DOCKER_HOST is inherited
doBuildBake builds cmd.Env from os.Environ() and then appends this function's values. With DOCKER_HOST=tcp://old:2375 docker --context desktop-linux compose build, the parent CLI selects desktop-linux because the explicit --context flag wins. This branch only appends DOCKER_CONTEXT=desktop-linux; it leaves the inherited DOCKER_HOST in cmd.Env. The child buildx CLI has no --context flag, and Docker CLI's resolveContextName checks DOCKER_HOST before DOCKER_CONTEXT, so it falls back to default and builds against the wrong daemon. Please remove inherited DOCKER_HOST and TLS overrides from the child environment for a named context, and test the combined environment passed to buildx with both variables set.
Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
|
@agammann |
What this PR does
With a named Docker context (e.g. Docker Desktop's
desktop-linux),docker compose buildignored the buildx builder selected for that context and reset the selection, because Compose always passedDOCKER_HOSTto the bake process and that makes the docker CLI resolve thedefaultcontext. This PR passes onlyDOCKER_CONTEXTfor a named context, and keeps passingDOCKER_HOSTand TLS material for thedefaultcontext, which is also the one in use with-HorDOCKER_HOST.Related issue
Fixes #14433
Changes made
pkg/compose/shellout.go:propagateDockerEndpointreturns onlyDOCKER_CONTEXT(andUSER_AGENT) when the current context is notcommand.DefaultContextName. A named context already carries its endpoint and TLS material, and the child CLI plugin resolves it by name, together with per-context state such as the selected buildx builder. For thedefaultcontext nothing changes.pkg/compose/shellout_test.go(new): table-drivenTestPropagateDockerEndpointcovering a named context, a named TLS context, thedefaultcontext, and thedefaultcontext with TLS. Before the fix, both named cases failed becauseDOCKER_HOSTwas set.Testing done
make testmake e2e-composeormake e2e-compose-standalonemake lintmake fmtAI tool used (if applicable)
AI Tool:
Additional context
This area has changed several times, so the new test pins all the cases the earlier fixes were about.
(not mandatory) A picture of a cute animal, if possible in relation to what you did