+0
Daily
5,773
stars
406
forks
2
watchers
80
prs
288
issues
0
releases
README
Deprecated NB: these images are deprecated in favor of AWS' official images, which you can find at: https://github.com/aws/aws-lambda-base-images And browse on the ECR public gallery, eg: https://gallery.ecr.aws/lambda/python This project is now archived and will not receive any further updates. docker-lambda A sandboxed local environment that replicates the live AWS Lambda environment almost identically – including installed software and libraries, file structure and permissions, environment variables, context objects and behaviors – even the user and running process are the same. You can use it for running your functions in the same strict Lambda environment, knowing that they'll exhibit the same behavior when deployed live. You can also use it to compile native dependencies knowing that you're linking to the same library versions that exist on AWS Lambda and then deploy using the AWS CLI. --- Contents Usage Run Examples Build Examples Using a Dockerfile to build Docker tags Verifying images Environment variables Build environment Questions --- Usage Running Lambda functions You can run your Lambdas from local directories using the -v arg with docker run. You can run them in two modes: as a single execution, or as an API server that listens for invoke events. The default is single execution mode, which outputs all logging to stderr and the result of the handler to stdout. You mount your (unzipped) lambda code at /var/task and any (unzipped) layer code at /opt, and most runtimes take two arguments – the first for the handler and the second for the event, ie: sh docker run --rm \ -v :/var/task:ro,delegated \ [-v :/opt:ro,delegated] \ lambci/lambda: \ [] [] (the --rm flag will remove the docker container once it has run, which is usually what you want, and the ro,delegated options ensure the directories are mounted read-only and have the highest performance) You can pass environment variables (eg -e AWS_ACCESS_KEY_ID=abcd) to talk to live AWS services, or modify aspects of the runtime. See below for a list. Running in "stay-open" API mode If you pass the environment variable DOCKER_LAMBDA_STAY_OPEN=1 to the container, then instead of executing the event and shutting down, it will start an API server (on port 9001 by default), which you can then call with HTTP following the Lambda Invoke API. This allows you to make fast subsequent calls to your handler without paying the "cold start" penalty each time. sh docker run --rm [-d] \ -e DOCKER_LAMBDA_STAY_OPEN=1 \ -p 9001:9001 \ -v :/var/task:ro,delegated \ [-v :/opt:ro,delegated] \ lambci/lambda: \ [] (the -d flag will start the container in detached mode, in the background) You should then see: sh Lambda API listening on port 9001... Then, in another terminal shell/window you can invoke your function using the AWS CLI (or any http client, like curl): sh aws lambda invoke --endpoint http://localhost:9001 --no-sign-request \ --function-
Top issues
#326Make images available in the AWS ECR Public Gallery23 comments · 2021-01-06#257how to test the response of a node lambda18 comments · 2020-03-06#329nodejs14.x support11 comments · 2021-02-04#244Debugging documentation11 comments · 2020-01-08#343Need support for python3.910 comments · 2021-08-20#353What is the status of this project?7 comments · 2021-10-03#109Unable to locate config file for .NET Core application7 comments · 2018-08-15#26Image provides tmpfs on /dev/shm7 comments · 2017-03-26