Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Changing lambda API and server to listen in the same port #235

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

wapmesquita
Copy link
Contributor

@wapmesquita wapmesquita commented Dec 13, 2019

This PR is to help users that need to start more than on docker containers in network mode host. With server listening in the hardcoded port 9001, it's not possible. So, my suggestion is to use the same variable to DOCKER_LAMBDA_API_PORT to the server.

My issue: I need to trigger more than one lambda at the same time and my network mode needs to be host. The first lambda run and starts listening on port 9001. When the second lambda run, the port 9001 is already in use throwing an error.

My suggestion is to make the server port customizable, so I can run the lambdas setting different port values.

Steps to reproduce

  • Terminal 1
$ nc -l -p 9001
  • Terminal 2
$ CONTAINER_ID="$(docker create -i   -e DOCKER_LAMBDA_USE_STDIN="$DOCKER_LAMBDA_USE_STDIN" -e HOSTNAME="$HOSTNAME" -e LOCALSTACK_HOSTNAME="$LOCALSTACK_HOSTNAME" -e AWS_LAMBDA_FUNCTION_NAME="$AWS_LAMBDA_FUNCTION_NAME" -e AWS_LAMBDA_FUNCTION_VERSION="$AWS_LAMBDA_FUNCTION_VERSION" -e AWS_LAMBDA_FUNCTION_INVOKED_ARN="$AWS_LAMBDA_FUNCTION_INVOKED_ARN"  --network="host" --rm "lambci/lambda:nodejs12.x" "index.foo")"; docker start -ai "$CONTAINER_ID";

How this is solved with this PR?
After this PR we could just to run the docker container with -e DOCKER_LAMBDA_API_PORT=9002

@mhart
Copy link
Member

mhart commented Dec 13, 2019

Hey, thanks for the contribution! Can you describe the problem you're seeing a little more with steps to reproduce? I'm not sure this is the right solution.

@wapmesquita
Copy link
Contributor Author

wapmesquita commented Dec 13, 2019

Hey, thanks for the contribution! Can you describe the problem you're seeing a little more with steps to reproduce? I'm not sure this is the right solution.

Thanks for your attention! :)

I am sure that there is much more to discuss. I updated the description to add more details

@mhart mhart merged commit cd1ab14 into lambci:master Dec 13, 2019
@mhart
Copy link
Member

mhart commented Dec 13, 2019

Ok gotcha. Added this in – although I don't think the runtime port should be tied to the api port, so I made the runtime port configurable as well with DOCKER_LAMBDA_RUNTIME_PORT

Thanks for the contribution! This is now live 👍

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

Successfully merging this pull request may close these issues.

2 participants