Skip to content

Add support for starting a container in multiple networks#40434

Open
beena352 wants to merge 6 commits intomicrosoft:masterfrom
beena352:user/beenachauhan/wslc-multi-network-container
Open

Add support for starting a container in multiple networks#40434
beena352 wants to merge 6 commits intomicrosoft:masterfrom
beena352:user/beenachauhan/wslc-multi-network-container

Conversation

@beena352
Copy link
Copy Markdown
Contributor

@beena352 beena352 commented May 6, 2026

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

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • [x ] Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

  • Added AdditionalNetworks array to WSLCContainerOptions in the IDL so callers can pass extra network names
  • Added AddAdditionalNetwork() method to WSLCContainerLauncher for easy use
  • On container create, all networks (primary + additional) are sent to Docker in one request using NetworkingConfig.EndpointsConfig
  • Container inspect now returns network details (IP, gateway, MAC address) for each attached network under NetworkSettings.Networks

Validation Steps Performed

Copilot AI review requested due to automatic review settings May 6, 2026 04:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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/AdditionalNetworksCount to WSLCContainerOptions and wired it through WSLCContainerLauncher into Docker’s NetworkingConfig.EndpointsConfig during container create.
  • Extended WSLC inspect schema to include NetworkSettings.Networks and 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).

Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/windows/service/inc/wslc.idl
@beena352 beena352 marked this pull request as ready for review May 6, 2026 13:49
@beena352 beena352 requested a review from a team as a code owner May 6, 2026 13:49
@beena352 beena352 requested a review from Copilot May 6, 2026 15:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

beena352 added 2 commits May 6, 2026 18:46
Copilot AI review requested due to automatic review settings May 8, 2026 00:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Comment thread localization/strings/en-US/Resources.resw
ULONG NamedVolumesCount;

[unique, size_is(AdditionalNetworksCount)] LPCSTR* AdditionalNetworks;
ULONG AdditionalNetworksCount;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Copilot AI review requested due to automatic review settings May 8, 2026 20:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/inc/docker_schema.h
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.

3 participants