Skip to content

fix(image-build): use default builder for local docker builds#442

Merged
ptone merged 2 commits into
GoogleCloudPlatform:mainfrom
subspacecoms:bug/fix-buildx-local-build
Jun 18, 2026
Merged

fix(image-build): use default builder for local docker builds#442
ptone merged 2 commits into
GoogleCloudPlatform:mainfrom
subspacecoms:bug/fix-buildx-local-build

Conversation

@subspacecoms

Copy link
Copy Markdown
Contributor

Using a custom docker-container builder (scion-builder) prevents BuildKit from resolving intermediate images built in previous steps when PUSH is false, because the container driver doesn't share the host's daemon image cache. Switching to the default builder for local builds resolves this.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request modifies the local Docker builder script to use the default builder when a push is not requested. The reviewer suggested using the BUILDX_BUILDER environment variable instead of running 'docker buildx use' to avoid mutating the user's global Docker CLI configuration.

Comment on lines +37 to +45
if [[ "${PUSH:-false}" != "true" ]]; then
if [[ "${DRY_RUN:-false}" == "true" ]]; then
echo "[dry-run] docker buildx use default"
return 0
fi
echo "Using default docker builder for local build..."
docker buildx use default
return 0
fi

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.

medium

Using docker buildx use <builder> mutates the user's global Docker CLI configuration (specifically ~/.docker/buildx/current), which permanently changes their active builder even after this script finishes executing. This can be disruptive to developers running the script locally.

Instead, you can use the BUILDX_BUILDER environment variable. Setting export BUILDX_BUILDER=default achieves the same result but is scoped only to the current script execution, leaving the user's global configuration untouched.

Note: You should also apply this pattern to the PUSH == true branch (lines 52-57) by using export BUILDX_BUILDER="${BUILDX_INSTANCE}" and removing the --use flag from docker buildx create.

Suggested change
if [[ "${PUSH:-false}" != "true" ]]; then
if [[ "${DRY_RUN:-false}" == "true" ]]; then
echo "[dry-run] docker buildx use default"
return 0
fi
echo "Using default docker builder for local build..."
docker buildx use default
return 0
fi
if [[ "${PUSH:-false}" != "true" ]]; then
if [[ "${DRY_RUN:-false}" == "true" ]]; then
echo "[dry-run] export BUILDX_BUILDER=default"
return 0
fi
echo "Using default docker builder for local build..."
export BUILDX_BUILDER="default"
return 0
fi

subspacecoms and others added 2 commits June 18, 2026 23:35
Using a custom docker-container builder (scion-builder) prevents BuildKit from resolving intermediate images built in previous steps when PUSH is false, because the container driver doesn't share the host's daemon image cache. Switching to the default builder for local builds resolves this.
… config

Address PR GoogleCloudPlatform#442 reviewer feedback:
- Use the BUILDX_BUILDER environment variable instead of 'docker buildx use' to prevent mutating the user's global Docker CLI configuration.
- For push builds, export BUILDX_BUILDER="${BUILDX_INSTANCE}" and remove the --use flag from 'docker buildx create'.
@ptone ptone force-pushed the bug/fix-buildx-local-build branch from 4ccb1f3 to 2ebea3c Compare June 18, 2026 22:36
@ptone ptone merged commit 71749c1 into GoogleCloudPlatform:main Jun 18, 2026
5 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.

2 participants