Support Docker-style network aliases in wslc#40972
Open
danegsta wants to merge 11 commits into
Open
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>
Contributor
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>
beena352
reviewed
Jul 2, 2026
beena352
reviewed
Jul 2, 2026
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>
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
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.