Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: sam build --use-container doesn't work with WSL2 networkingMode=mirrored #6017

Open
mew1033 opened this issue Sep 30, 2023 · 3 comments

Comments

@mew1033
Copy link

mew1033 commented Sep 30, 2023

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: microsoft/WSL#10494 (comment) 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:

self._start_port_range = 5000
self._end_port_range = 9000

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
@mew1033 mew1033 added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Sep 30, 2023
@sriram-mv
Copy link
Contributor

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:

The ports are chosen at random between 5000-9000 so that you could run multiple sam local invokes, start-api, start-lambda etc in parallel. There is no certain set of ports that you could allow. However when you setup debugging, there is a port number that you can pass in the arguments which could be allowlisted.

@sriram-mv sriram-mv added platform/windows area/docker and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Oct 5, 2023
@mew1033
Copy link
Author

mew1033 commented Oct 7, 2023

The ports are chosen at random between 5000-9000 so that you ...

While I appreciate being able to run multiple sam commands in parallel, it's those 4000 ports I'd like to be able to customize. On my personal machine, I don't ever run enough simultaneous sam commands to need 4000 ports. I'd love it if I could customize that range.

@sriram-mv sriram-mv added type/feature Feature request contributors/good-first-issue Good first issue for a contributor and removed contributors/good-first-issue Good first issue for a contributor labels Oct 9, 2023
@sriram-mv
Copy link
Contributor

Interesting, an override of the behavior could be something that is supported. Happy to accept a proposal/PR on this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants