AWS Lambda Docker Image: How do you automatically run handler after starting container?

Viewed 22

For reference, I am trying to run a lambda handler inside a docker container locally on my machine.

I have been using this guide from AWS and can complete all the steps outlined successfully. To test the function locally they provide these steps:

  1. Run your image locally:
docker run -p 9000:8080 <image name>
  1. In a separate terminal, you can then locally invoke the function using cURL:
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'

This works, but I am trying to do this process programmatically through a script, so I've been wondering:

Is there a way to automatically invoke the handler after starting the container and having it close immediately after, rather than needing to invoke it manually with cURL?

What tells the container to invoke the handler after it receives a POST request? Any insight into this would be much appreciated.

0 Answers
Related