Add --network option to container create/run (excluding host mode)#40720
Open
AmelBawa-msft wants to merge 8 commits into
Open
Add --network option to container create/run (excluding host mode)#40720AmelBawa-msft wants to merge 8 commits into
AmelBawa-msft wants to merge 8 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds --network support to the WSLC container run and container create commands, allowing users to attach containers to one or more networks by flowing the option through CLI parsing, validation, task option mapping, and container launch.
Changes:
- Add
--networkas a repeatable CLI option forcontainer run/create, validate non-empty values, and localize new help/error strings. - Extend container options/model + task parsing to carry a list of networks and apply them at container creation (primary network + additional networks).
- Add unit + E2E coverage for default network behavior, host mode, user-defined networks, and rejected inputs.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/windows/wslc/WSLCCLIExecutionUnitTests.cpp | Adds unit tests validating --network parsing and that options populate correctly. |
| test/windows/wslc/e2e/WSLCE2EContainerRunTests.cpp | Adds E2E coverage for default/host/user-defined networks and input rejection for container run. |
| test/windows/wslc/e2e/WSLCE2EContainerCreateTests.cpp | Updates expected help text to include --network for container create. |
| src/windows/wslc/tasks/ContainerTasks.cpp | Maps parsed --network args into ContainerOptions.Networks. |
| src/windows/wslc/services/ContainerService.cpp | Applies selected networks when launching containers (primary mode + additional networks). |
| src/windows/wslc/services/ContainerModel.h | Extends ContainerOptions with a Networks vector. |
| src/windows/wslc/commands/ContainerRunCommand.cpp | Registers --network as a repeatable argument for container run. |
| src/windows/wslc/commands/ContainerCreateCommand.cpp | Registers --network as a repeatable argument for container create. |
| src/windows/wslc/arguments/ArgumentValidation.cpp | Adds validation rejecting empty/whitespace --network values; localizes workdir empty error. |
| src/windows/wslc/arguments/ArgumentDefinitions.h | Adds Network argument definition wired to localized description. |
| localization/strings/en-US/Resources.resw | Adds localized --network description + network/workdir empty error strings. |
OneBlue
requested changes
Jun 5, 2026
Copilot
AI
changed the title
Add --network option to container create/run
Add --network option to container create/run (excluding host mode)
Jun 6, 2026
OneBlue
reviewed
Jun 6, 2026
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
Adds
--networksupport tocontainer runandcontainer create, letting users connect containers to one or more networks.--network hostis explicitly rejected with the error:host mode networking is not supported, and this message is now localized.PR Checklist
Detailed Description of the Pull Request / Additional comments
--networkvalue ishost, command execution fails with:host mode networking is not supportedcontainer createandcontainer runhost-mode cases to expect failure.--networkoptions are provided and one of them ishost.Validation Steps Performed
clang-format -ion changed files.clang-format --dry-run --style=fileon changed files.python3 tools/devops/validate-localization.py.