Skip to content

Support Docker-style network aliases in wslc#40972

Open
danegsta wants to merge 11 commits into
microsoft:masterfrom
danegsta:danegsta-microsoft-support-network-aliases
Open

Support Docker-style network aliases in wslc#40972
danegsta wants to merge 11 commits into
microsoft:masterfrom
danegsta:danegsta-microsoft-support-network-aliases

Conversation

@danegsta

@danegsta danegsta commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary of the Pull Request

This adds Docker-style per-network alias support to wslc container run and wslc container create so aliases can be scoped directly in each --network value. This makes multi-network container creation less ambiguous while preserving the existing --network-alias behavior 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 where alias appears before name. 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, and container: networking modes, and ambiguous --network-alias usage with multiple networks is still rejected. The lower-level endpoint setting parser only accepts the Aliases key so unsupported endpoint settings fail explicitly.

Validation Steps Performed

  • Ran cmake --fresh . after setting up the Windows build environment.
  • Ran the Windows build successfully before local dev-loop deployment configuration was added.
  • Ran focused build after parser/localization changes: cmake --build . --target wslc wsltests -- -m.
  • Ran elevated network alias test subset: bin\x64\Debug\test.bat /name:*NetworkAlias*.
  • Smoke tested with a real deployed wslc.exe: created user-defined networks, started containers with per-network aliases, confirmed inspect output included the aliases, and verified DNS alias resolution from peer containers on the same network.

danegsta and others added 4 commits June 30, 2026 17:42
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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>
Copilot AI review requested due to automatic review settings July 1, 2026 23:08
@danegsta danegsta requested a review from a team as a code owner July 1, 2026 23:08

Copilot AI 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.

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 --network values into { name, aliases[] } and validate new error cases (empty alias, duplicate name=, 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.

Comment thread localization/strings/en-US/Resources.resw
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread test/windows/wslc/WSLCCLIExecutionUnitTests.cpp
Comment thread src/windows/wslc/services/ContainerModel.h Outdated
Comment thread src/windows/wslc/arguments/ArgumentValidation.cpp Outdated
Comment thread src/windows/wslc/arguments/ArgumentValidation.cpp Outdated
Comment thread src/windows/wslc/services/ContainerModel.h Outdated
Comment thread src/windows/wslc/services/ContainerModel.h Outdated
Comment thread src/windows/wslc/services/ContainerModel.h Outdated
Comment thread src/windows/wslc/services/ContainerModel.h Outdated
Comment thread src/windows/wslc/services/ContainerService.cpp
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 3, 2026 00:03

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

danegsta and others added 2 commits July 2, 2026 17:17
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 3, 2026 00:33

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
danegsta and others added 2 commits July 2, 2026 17:38
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 3, 2026 00:52

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
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>
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.

Support network aliases in wslc container run/create --network arguments

4 participants