Add support for starting a container in multiple networks#40434
Open
beena352 wants to merge 6 commits intomicrosoft:masterfrom
Open
Add support for starting a container in multiple networks#40434beena352 wants to merge 6 commits intomicrosoft:masterfrom
beena352 wants to merge 6 commits intomicrosoft:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends WSLC container creation/inspection to support attaching a container to multiple Docker networks at create time, and surfaces per-network endpoint details in inspect.
Changes:
- Added
AdditionalNetworks/AdditionalNetworksCounttoWSLCContainerOptionsand wired it throughWSLCContainerLauncherinto Docker’sNetworkingConfig.EndpointsConfigduring container create. - Extended WSLC inspect schema to include
NetworkSettings.Networksand mapped Docker inspect per-endpoint fields (IP, gateway, MAC, prefix length). - Added Windows tests covering multi-network attach, invalid/rejected scenarios (host/none, duplicates, invalid names, missing network), and deleting an in-use additional network.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Adds end-to-end WSLC tests for multi-network container creation and validation/error cases. |
| src/windows/wslcsession/WSLCContainer.cpp | Implements additional network processing in create request, post-create attachment verification, and inspect network mapping. |
| src/windows/service/inc/wslc.idl | Extends container options struct to accept additional network name array. |
| src/windows/inc/wslc_schema.h | Adds WSLC inspect schema types for per-network endpoint settings under NetworkSettings.Networks. |
| src/windows/inc/docker_schema.h | Adds Docker schema support for NetworkingConfig on create and NetworkSettings.Networks on inspect/list parsing. |
| src/windows/common/WSLCContainerLauncher.h | Adds AddAdditionalNetwork() API and storage for additional networks. |
| src/windows/common/WSLCContainerLauncher.cpp | Populates new WSLCContainerOptions.AdditionalNetworks* fields from launcher state. |
| localization/strings/en-US/Resources.resw | Adds new localized user-facing messages for invalid additional-network scenarios (primary mode restriction, duplicate network). |
…eenachauhan/wslc-multi-network-container
…eenachauhan/wslc-multi-network-container
OneBlue
reviewed
May 8, 2026
| ULONG NamedVolumesCount; | ||
|
|
||
| [unique, size_is(AdditionalNetworksCount)] LPCSTR* AdditionalNetworks; | ||
| ULONG AdditionalNetworksCount; |
Collaborator
There was a problem hiding this comment.
Instead of adding an additional field, I recommend making updating WSLCContainerNetwork::ContainerNetworkName to be an array instead. I think we should probably have a structure to define a custom network attachment, something like:
struct WSLCNetworkAttachment
{
string NetworkName;
optional<string> ContainerIpAddress;
};
(that will allow us to implement --ip later in a followup change)
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 support for attaching a container to more than one network when it is created. Before this change, a container could only be connected to a single network. Now additional network names can be passed alongside the primary network, and the container will be connected to all of them at create time.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed