Open mew1033 opened 1 year ago
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.
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.
Interesting, an override of the behavior could be something that is supported. Happy to accept a proposal/PR on this one!
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 theignoredPorts
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)
sam --version
: 1.97.0