Support Docker-style network aliases in wslc - #40972
Support Docker-style network aliases in wslc#40972David Negstad (danegsta) wants to merge 19 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…support-network-aliases
Treat any --network value containing key/value separators as Docker-style advanced network syntax so aliases can appear before name=. Add run/create parser coverage for alias-before-name ordering. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Docker-style per-network alias parsing for wslc container run/create (e.g. --network name=net,alias=a,alias=b), carries aliases through the container options/model into the launcher and session layers, and ensures aliases are applied on both primary and additional network endpoints.
Changes:
- Parse
--networkvalues into{ name, aliases[] }and validate new error cases (empty alias, duplicatename=, unsupported option keys). - Plumb per-network aliases through the container model/service/launcher into
WSLCNetworkConnection.Settings(endpoint settings) for additional networks and into the primary endpoint configuration. - Add/adjust unit + e2e coverage for multi-network Docker-style alias behavior and for rejecting unsupported endpoint settings.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Updates endpoint-settings rejection test and adds coverage for aliases across primary + additional networks. |
| test/windows/wslc/WSLCCLIExecutionUnitTests.cpp | Updates expectations for new Networks model shape and adds parser unit tests for Docker-style --network ... alias=.... |
| test/windows/wslc/e2e/WSLCE2EContainerRunTests.cpp | Adds e2e test ensuring Docker-style aliases work across multiple networks for container run. |
| test/windows/wslc/e2e/WSLCE2EContainerCreateTests.cpp | Adds e2e test ensuring Docker-style aliases work across multiple networks for container create. |
| src/windows/wslcsession/WSLCContainer.cpp | Implements endpoint settings parsing for Aliases and rejects unsupported keys; applies alias validation for primary/additional endpoints. |
| src/windows/wslc/tasks/ContainerTasks.cpp | Populates ContainerOptions.Networks with parsed Name + Aliases from --network. |
| src/windows/wslc/services/ContainerService.cpp | Validates alias support by network mode and forwards per-network aliases into the launcher. |
| src/windows/wslc/services/ContainerModel.h | Introduces ContainerNetwork and ParseNetworkArgument() to parse Docker-style --network values. |
| src/windows/wslc/arguments/ArgumentValidation.cpp | Validates new parse errors for --network (empty alias, duplicate name, unsupported keys). |
| src/windows/service/inc/wslc.idl | Documents that per-endpoint settings are KVP-encoded and may include duplicate keys. |
| src/windows/common/WSLCContainerLauncher.h | Extends launcher API/storage to support additional-network aliases. |
| src/windows/common/WSLCContainerLauncher.cpp | Encodes additional-network aliases into WSLCNetworkConnection.Settings as repeated Aliases KVPs. |
| localization/strings/en-US/Resources.resw | Adds new CLI validation strings for duplicate name= and unsupported --network options. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reject endpoint aliases on non-user-defined additional network names before the network lookup so built-in modes get the same user-facing error as primary network aliases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
LGTM! Thanks for addressing the feedback. Blue (@OneBlue) could you take a look? |
Blue (OneBlue)
left a comment
There was a problem hiding this comment.
Overall structure LGTM. Couple minor comments
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f013920a-4281-4fe8-97d2-5e2497753a51
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
localization/strings/en-US/Resources.resw:2995
- The for WSLCCLI_NetworkUnsupportedOptionError includes two {FixedPlaceholder="{}"} markers, but tools/devops/validate-localization.py’s generate_string_comment() emits only a single FixedPlaceholder marker when any insert exists. With two markers, the validator’s expected substring won’t match contiguously and localization validation is likely to fail.
<comment>{FixedPlaceholder="{}"}{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1771dae2-0542-488e-a19d-5605782222de
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f013920a-4281-4fe8-97d2-5e2497753a51
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f013920a-4281-4fe8-97d2-5e2497753a51
Summary of the Pull Request
This adds Docker-style per-network alias support to
wslc container runandwslc container createso aliases can be scoped directly in each--networkvalue. This makes multi-network container creation less ambiguous while preserving the existing--network-aliasbehavior for single-network cases.PR Checklist
Fixes #40970
Detailed Description of the Pull Request / Additional comments
The CLI now accepts Docker-style network values such as
--network name=my-net,alias=api,alias=backend, including values wherealiasappears beforename. Parsed aliases are carried through the container task model into the service and launcher layers, then passed as endpoint settings for both the primary and additional network attachments.Alias validation remains scoped to user-defined networks: aliases are rejected for built-in
bridge,host,none, andcontainer:networking modes, and ambiguous--network-aliasusage with multiple networks is still rejected. The lower-level endpoint setting parser only accepts theAliaseskey so unsupported endpoint settings fail explicitly.Validation Steps Performed
cmake --fresh .after setting up the Windows build environment.cmake --build . --target wslc wsltests -- -m.bin\x64\Debug\test.bat /name:*NetworkAlias*.wslc.exe: created user-defined networks, started containers with per-network aliases, confirmedinspectoutput included the aliases, and verified DNS alias resolution from peer containers on the same network.