Skip to content

builder: preserve selected builder for docker bake - #7154

Open
wpan36 wants to merge 1 commit into
docker:masterfrom
wpan36:7125-bake-builder-selection
Open

builder: preserve selected builder for docker bake#7154
wpan36 wants to merge 1 commit into
docker:masterfrom
wpan36:7125-bake-builder-selection

Conversation

@wpan36

Copy link
Copy Markdown

- What I did

Fixed top-level docker bake so it preserves the builder selected with
docker buildx use, instead of overriding it with the active Docker
context's implicit docker-driver builder.

The existing compatibility behavior for docker build remains unchanged.

Fixes#7125

- How I did it

Top-level docker bake is forwarded to docker buildx bake, but it was
also passing through the generic forwarded-command compatibility block
that injects:

BUILDX_BUILDER=<current Docker context>

That override is intended for traditional docker build commands so they
continue using the current context builder and load results into the local
image store.

This change skips that environment-variable injection for top-level
docker bake, allowing Buildx to perform its normal selected-builder
resolution.

I also extended the existing table-driven test to cover different forwarded
commands and added a regression case for Bake with a custom Docker context.

- How to verify it

Automated validation performed:

  • TestForwardedCommandWithBuilder
  • Complete cmd/docker package tests
  • Complete unit-test suite: 2,559 tests passed, 4 skipped
  • golangci-lint: 0 issues
  • ShellCheck

Manual verification used a non-default Docker context and a selected
docker-container builder.

Before the fix:

docker bake -> context builder / docker driver
docker buildx bake -> selected builder / docker-container driver

After the fix:

docker bake -> selected builder / docker-container driver
docker buildx bake -> selected builder / docker-container driver
docker build -> context builder / docker driver

- Human readable description for the release notes

Make `docker bake` honor the builder selected with `docker buildx use`.

- A picture of a cute animal (not mandatory but encouraged)

Not included.

Signed-off-by: Weijun Pan <wpan3636@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant

@wpan36