Using PortMappings in WSL.Container throws "incorrect parameter"
@florelis is already working on this.
Since Jul 6, 2026.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Windows Version
Microsoft Windows [Version 10.0.26200.8655]
### WSL Version
2.9.3.0
### Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
### Kernel Version
Whatever runs WSLC
### Distro Version
Whatever runs WSLC
### Other Software
NuGet: Microsoft.WSL.Containers 2.9.3
### Repro Steps
```
var containerSettings = new ContainerSettings(ImageName)
{
Name = ContainerName,
EnableAutoRemove = true,
PortMappings = new List()
{
new (windowsPort: 8080,
containerPort: 8080,
protocol: PortProtocol.TCP),
},
};
container = session.CreateContainer(containerSettings);
```
The following does not throw any exception, though does not map ports either.
```
var containerSettings = new ContainerSettings(ImageName)
{
Name = ContainerName,
EnableAutoRemove = true,
};
container = session.CreateContainer(containerSettings);
```
### Expected Behavior
Something like
```
wslc --session MySession run --rm -p 8080:8080 --name MyContainer MyImage
```
### Actual Behavior
```
System.ArgumentException: 'The parameter is incorrect.
The parameter is incorrect.
'
```
### Diagnostic Logs
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.