Bug: sam build --use-container doesn't work with WSL2 `networkingMode=mirrored`
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description:
WSL2 just introduced a new networking mode: `networkingMode=mirrored`. It's awesome. Fixes a lot of problems people have with using WSL while connected to a corporate VPN. https://devblogs.microsoft.com/commandline/windows-subsystem-for-linux-september-2023-update/
However, there is something wrong with binding ports in docker when this new method is set. It makes it impossible to sam build in a container. It errors out indicating the port is already in use. There's a (IMO, dumb) workaround that gets sam build working again: https://github.com/microsoft/WSL/issues/10494#issuecomment-1734567875 However, you have to add _every_ port, separated by commas, to the `ignoredPorts` config item.
This is definitely a WSL issue. However, it'd be nice if we could specify which ports sam uses with docker while building to make it easier to apply this workaround. Right now, the values are listed here: https://github.com/aws/aws-sam-cli/blob/c5b9b1e399a1e5c938ef72934a14ede934e17bac/samcli/local/docker/container.py#L124-L125
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
1. OS: Windows 11 (22621.2361)
2. `sam --version`: 1.97.0
3. AWS region: us-west-2
Contributor guide
Assessment
This issue has not been assessed yet.