microsoft / microsoft/WSL

Using PortMappings in WSL.Container throws "incorrect parameter"

Open
#40,991 6 comments 0 reactions 1 assignee View on GitHub

@florelis is already working on this.

Since Jul 6, 2026.

bydesign enhancement wslc
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

Image

```
System.ArgumentException: 'The parameter is incorrect.

The parameter is incorrect.
'
```

### Diagnostic Logs

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.