wslc: switch image build from docker build to docker buildx build#41133
Open
beena352 wants to merge 5 commits into
Open
wslc: switch image build from docker build to docker buildx build#41133beena352 wants to merge 5 commits into
beena352 wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates WSLC session image builds to invoke BuildKit via docker buildx build (instead of classic docker build) inside the container VM, as a preparatory step for enforcing registry allowlist policy via BuildKit source-policy in a follow-up change.
Changes:
- Switched the in-VM image build command from
docker buildtodocker buildx buildwhile preserving--progress=rawjsonand the existing argument construction.
beena352
marked this pull request as ready for review
July 21, 2026 23:33
benhillis
requested changes
Jul 22, 2026
benhillis
left a comment
Member
There was a problem hiding this comment.
The direct Buildx invocation loses Docker CLI forwarding behavior that guarantees the result is loaded into the local image store.
Copilot-Session: a404d085-142f-448f-b7fa-7ccc6528e844
Reverts commit 035bc00. Copilot-Session: a404d085-142f-448f-b7fa-7ccc6528e844
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/windows/wslcsession/WSLCSession.cpp:917
docker buildx builddoes not necessarily load the resulting image into the local Docker image store unless an output is specified (e.g.,--load/--push). If buildx ends up using thedocker-containerdriver (common when a non-default builder is active), this invocation can succeed but leave no image/tag available afterward, which would be a behavior change vsdocker build. Add--load(or explicitly select a docker driver/builder) to preserve the previous semantics that the built image is usable immediately via the daemon.
std::vector<std::string> buildArgs{"/usr/bin/docker", "buildx", "build", "--progress=rawjson"};
…ld-switch-to-buildx' into user/beenachauhan/wslc-image-build-switch-to-buildx
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.
Summary of the Pull Request
Change the command wslc runs inside the container VM for wslc image build from docker build to docker buildx build. Zero behavior change, same flags, same context mount, same rawjson output parsed by the existing BuildKitSolveStatus parser.
This is a preparatory PR. It unblocks a follow-up that will enforce the WSLContainerRegistryAllowlist group policy on image builds. Classic docker build cannot honor a BuildKit source policy; docker buildx build can. Splitting the invocation swap from the policy logic keeps both PRs small and gives a clean bisect point.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Why we're doing this
The WSLContainerRegistryAllowlist group policy (added in #40466) lists which registries wslc may talk to. PullImage and PushImage enforce it per-call, but BuildImage couldn't, a Dockerfile's FROMs resolve inside dockerd via ARGs, COPY --from=, --build-context, etc., which we can't reliably parse client-side. So #40466 took the strict-secure default: whenever the allowlist is configured, every wslc image build is refused outright. That leaves enterprise customers with the policy enabled unable to build images at all, even from an allowed registry.
The follow-up PR fixes that by pushing enforcement into BuildKit itself, via its per-invocation source-policy JSON (evaluated after ARG substitution, before any registry request). The catch: classic docker build in moby v25.0.7 silently drops the SourcePolicy field, no CLI flag or env var fills it in. docker buildx build with the default docker driver speaks BuildKit gRPC directly, so SourcePolicy (via EXPERIMENTAL_BUILDKIT_SOURCE_POLICY) travels intact.
This PR makes wslc image build go through buildx so the follow-up can enforce the policy. That's it.
Zero-behavior-change verification
Argv shape: buildx accepts every flag BuildImage passes (--progress=rawjson, -f -, -t, --build-arg, --label, --target, --no-cache, --pull) plus the mounted context path - unchanged.
Rawjson stream: all 14 fields the C++ parser destructures (vertexes, statuses, logs, digest, name, started, completed, error, id, vertex, current, total, data, stream) parse identically.
VM availability: buildx already ships at /usr/libexec/docker/cli-plugins/docker-buildx (BuildKit v0.12.5) - no new dependency.
Validation Steps Performed