Skip to content

Add container:<name id> network mode for WSLC containers#40502

Open
beena352 wants to merge 10 commits into
microsoft:masterfrom
beena352:user/beenachauhan/wslc-container-network-mode
Open

Add container:<name id> network mode for WSLC containers#40502
beena352 wants to merge 10 commits into
microsoft:masterfrom
beena352:user/beenachauhan/wslc-container-network-mode

Conversation

@beena352
Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds support for Docker's container:<name|id> network mode, allowing a WSLC container to share the network namespace of an existing container.

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

  • IDL: Added WSLCContainerNetworkTypeContainer = 4 enum value
  • DockerNetworkModeToWSLCNetworkType now returns a DockerNetworkMode struct with {Type, TargetId}, parsing "container:" from Docker's stored network mode
  • ProcessPortMappings resolves the target container via DockerHTTPClient::InspectContainer, canonicalizing the name to Docker's 64-char ID. Validates: empty target → E_INVALIDARG, target not found → WSLC_E_CONTAINER_NOT_FOUND (HTTP 404), ports with container mode → E_INVALIDARG. Argument validation runs before the Docker lookup
  • ProcessAdditionalNetworks rejects additional networks for container mode before the host/none check
  • GetAdditionalStartIndex and GetPrimaryNetworkName updated to handle WSLCContainerNetworkTypeContainer alongside Custom
  • Open() recovery path correctly reconstructs container-mode containers; HostConfig.NetworkMode round-trips via Docker's stored state
  • Empty target rejected in parser ("container:" → E_INVALIDARG)
  • WSLCContainerLauncher.cpp: Builds WSLCNetworkAttachment for Container type alongside Custom

Validation Steps Performed

Copilot AI review requested due to automatic review settings May 11, 2026 20:57
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for Docker’s container:<name|id> network mode in WSLC so a container can share another container’s network namespace, alongside expanded support for attaching multiple networks.

Changes:

  • Introduces WSLCContainerNetworkTypeContainer and parses/round-trips Docker container:<id> network mode.
  • Reworks container network options to support multiple network attachments and validates unsupported combinations (ports/additional networks with container mode).
  • Extends inspect/network schema and adds tests for container-mode and multi-network behaviors.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/windows/WSLCTests.cpp Adds coverage for multi-network attach behavior and container network mode validation/round-trip.
src/windows/wslcsession/WSLCContainer.cpp Implements container network mode resolution, additional network validation/attachment, and inspect network mapping.
src/windows/service/inc/wslc.idl Adds new network type and changes the network options struct to support multiple attachments.
src/windows/inc/wslc_schema.h Extends inspect schema to include per-network endpoint settings.
src/windows/inc/docker_schema.h Adds create-time NetworkingConfig and inspect-time NetworkSettings schema support.
src/windows/common/WSLCContainerLauncher.h Adds launcher API for specifying additional networks.
src/windows/common/WSLCContainerLauncher.cpp Builds WSLCNetworkAttachment[] for primary + additional networks in container options.
localization/strings/en-US/Resources.resw Adds localized strings for new validation errors and reserved fields.

Comment thread src/windows/service/inc/wslc.idl
Comment thread test/windows/WSLCTests.cpp
Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Comment thread localization/strings/en-US/Resources.resw
@beena352 beena352 marked this pull request as ready for review May 11, 2026 21:43
@beena352 beena352 requested a review from a team as a code owner May 11, 2026 21:43
Copilot AI review requested due to automatic review settings May 11, 2026 21:43
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.

Comments suppressed due to low confidence (1)

src/windows/inc/docker_schema.h:1

  • Adding NetworkingConfig as a non-optional field changes the serialized JSON for all container creates, including those that don’t use additional networks (it will still serialize an empty NetworkingConfig/EndpointsConfig). To minimize risk of Docker API behavior differences/regressions and reduce payload noise, consider making NetworkingConfig optional (or customizing serialization) so it’s only present when EndpointsConfig is non-empty.
/*++

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Comment thread localization/strings/en-US/Resources.resw
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.

2 participants