Skip to content

Using PortMappings in WSL.Container throws "incorrect parameter" #40991

Description

@hultqvist

Windows Version

Microsoft Windows [Version 10.0.26200.8655]

WSL Version

2.9.3.0

Are you using WSL 1 or WSL 2?

  • 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<ContainerPortMapping>()
     {
         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

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions