The answer was solved by @thesynde mentioning that I was infact importing all the files inside of my src folder and not the folder itself.
This was fixed by changing the copy command to
COPY . ${LAMBDA_TASK_ROOT}
and it working.
Answer from Ben Muller on Stack OverflowDocker Hub
hub.docker.com › r › amazon › aws-lambda-python
amazon/aws-lambda-python - Docker Image
FROM public.ecr.aws/lambda/python:3.8 # Copy function code COPY app.py ${LAMBDA_TASK_ROOT} # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) CMD [ "app.handler" ] Copy · You can then locally test your function using the docker build and docker run commands.
AWS
docs.aws.amazon.com › aws prescriptive guidance › patterns › compute › containers & microservices › deploy lambda functions with container images
Deploy Lambda functions with container images - AWS Prescriptive Guidance
Strive to have static layers higher up in your Docker file list, and place layers that change more often lower down. This improves caching, which improves performance. The image owner is responsible for updating and patching the image. Add that update cadence to your operational processes. For more information, see the AWS Lambda documentation. ... FROM public.ecr.aws/lambda/python:3.xx # Copy function code COPY app.py ${LAMBDA_TASK_ROOT} COPY requirements.txt ${LAMBDA_TASK_ROOT} # install dependencies RUN pip3 install --user -r requirements.txt # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) CMD [ "app.lambda_handler" ]
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python › deploy python lambda functions with container images
Deploy Python Lambda functions with container images - AWS Lambda
Use the COPY command to copy the function code and runtime dependencies to {LAMBDA_TASK_ROOT}, a Lambda-defined environment variable. Set the CMD argument to the Lambda function handler. Note that the example Dockerfile does not include a USER instruction
Stack Overflow
stackoverflow.com › questions › 68857752 › aws-lambda-using-container-image-but-still-getting-program-path-not-found
python - AWS Lambda: Using container image but still getting program path not found - Stack Overflow
I used this: FROM public.ecr.aws/lambda/python:3.8 # Copy function code COPY app.py ${LAMBDA_TASK_ROOT} # Install the function's dependencies using file requirements.txt # from your project folder. COPY requirements.txt . RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) CMD [ "app.handler" ] Do I need to change CMD filed?
Docker Hub
hub.docker.com › r › amazon › aws-lambda-java
amazon/aws-lambda-java - Docker Image
FROM public.ecr.aws/lambda/java:11 # Copy function code and runtime dependencies from Maven layout COPY target/classes ${LAMBDA_TASK_ROOT} COPY target/dependency/* ${LAMBDA_TASK_ROOT}/lib/ # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) CMD [ "com.example.LambdaHandler::handleRequest" ] Copy ·
Medium
medium.com › innovation-res › setup-custom-aws-lambda-λ-function-using-docker-containers-f434a18dfb7f
Setup Custom AWS lambda (λ) function dependencies using Docker containers | by George Bakas | Innovation-res | Medium
July 21, 2022 - FROM public.ecr.aws/lambda/python:3.8ENV S3_BUCKET=##### ENV S3_KEY=###### ENV S3_SECRET=######## Install Python dependencies for function COPY requirements.txt . RUN pip install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"COPY . ${LAMBDA_TASK_ROOT}CMD [ "app.handler" ] As you can see, this is a barely easy to understand and deploy Dockerfile.
AWS re:Post
repost.aws › questions › QUsO9ZXVWnTESVOyQnEQmjvA › problem-starting-docker-image-as-lambda-function-source
Problem starting Docker image as lambda function source | AWS re:Post
January 30, 2021 - RUN pip install -r requirements.txt COPY custom_module ${LAMBDA_TASK_ROOT} COPY app.py ${LAMBDA_TASK_ROOT} CMD \[app.lambda_handler] The function to run in app.py is definitely called lambda_handler, and I've run out of things to change. ... Here is what I have as a Dockerfile that is working for me, this may work for you too.
AWS re:Post
repost.aws › knowledge-center › lambda-container-images
Use container images with Lambda | AWS re:Post
July 25, 2024 - On your local machine, create one folder with three files: Dockerfile, requirements.txt with libraries, and app.py with import statements. Note: Use the latest version of Python for Amazon Elastic Container Registry (Amazon ECR) public registry. ... FROM public.ecr.aws/lambda/python:3.8 # Copy function code COPY app.py ${LAMBDA_TASK_ROOT} # Install the function's dependencies using file requirements.txt # from your project folder.
GitHub
github.com › lambci › docker-lambda › blob › master › base › Dockerfile
docker-lambda/base/Dockerfile at master · lambci/docker-lambda
January 15, 2023 - LAMBDA_TASK_ROOT=/var/task \ LAMBDA_RUNTIME_DIR=/var/runtime \ _LAMBDA_CONTROL_SOCKET=14 \ _LAMBDA_SHARED_MEM_FD=11 \ _LAMBDA_LOG_FD=9 \ _LAMBDA_SB_ID=7 \ _LAMBDA_CONSOLE_SOCKET=16 \ _LAMBDA_RUNTIME_LOAD_TIME=1530232235231 \ _AWS_XRAY_DAEMON_ADDRESS=169.254.79.2 \ _AWS_XRAY_DAEMON_PORT=2000 \ AWS_XRAY_DAEMON_ADDRESS=169.254.79.2:2000 \ AWS_XRAY_CONTEXT_MISSING=LOG_ERROR \ _X_AMZN_TRACE_ID='Root=1-dc99d00f-c079a84d433534434534ef0d;Parent=91ed514f1e5c03b2;Sampled=1' ·
Author lambci
GitHub
github.com › lambci › docker-lambda › issues › 20
using docker-lambda for local function development · Issue #20 · lambci/docker-lambda
January 26, 2017 - here's the second Dockerfile in case you wanted to see it (uses the same compose) # basically a copy of lambci/lambda FROM lambci/lambda:build ENV PATH=$PATH:/usr/local/lib64/node-v4.3.x/bin:/usr/local/bin:/usr/bin/:/bin \ LAMBDA_TASK_ROOT=/var/task \ LAMBDA_RUNTIME_DIR=/var/runtime \ ...
Author lifeispeachy301
Stack Overflow
stackoverflow.com › questions › 76000127 › directory-of-files-containerized-and-deployed-in-lambda
python - Directory of files containerized and deployed in Lambda? - Stack Overflow
I have a Python package directory for which looks like this: I have a Dockerfile which uses AWS provided base image: COPY requirements.txt . RUN pip install --upgrade pip ENV LAMBDA_TASK_ROOT=&qu...
Fpgmaas
fpgmaas.com › blog › aws-cdk-lambdas-docker
Deploying Python Lambda functions using Docker
October 9, 2022 - FROM public.ecr.aws/lambda/python:3.9-arm64 ENV POETRY_VERSION=1.1.13 # Install poetry RUN pip install "poetry==$POETRY_VERSION" # Copy only requirements to cache them in docker layer WORKDIR ${LAMBDA_TASK_ROOT} COPY poetry.lock pyproject.toml ${LAMBDA_TASK_ROOT}/ # Project initialization: RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root # Copy our Flask app to the Docker image COPY src ${LAMBDA_TASK_ROOT}/ # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) CMD [ "lambda_1.index.handler" ] There's no rocket science here.
GitHub
github.com › aws › aws-parallelcluster-ui › blob › main › Dockerfile.awslambda
aws-parallelcluster-ui/Dockerfile.awslambda at main · aws/aws-parallelcluster-ui
COPY --from=frontend-awslambda /app/build ${LAMBDA_TASK_ROOT}/frontend/public · · COPY resources/attributions/docker-attributions.txt license.txt · COPY requirements.txt . RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" · COPY app.py ${LAMBDA_TASK_ROOT} COPY api ${LAMBDA_TASK_ROOT}/api ·
Author aws
GitHub
github.com › lambci › docker-lambda
GitHub - lambci/docker-lambda: Docker images and test runners that replicate the live AWS Lambda environment · GitHub
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:
Starred by 5.8K users
Forked by 413 users
Languages C# 22.5% | JavaScript 18.3% | Go 18.3% | Python 13.3% | Dockerfile 12.8% | Java 10.2%
GitHub
github.com › aws-samples › aws-cdk-lambda-container › blob › master › README.md
aws-cdk-lambda-container/README.md at master · aws-samples/aws-cdk-lambda-container
August 12, 2024 - The ${LAMBDA_TASK_ROOT} represents the path to our Lambda functions as documented in the AWS Documentation on using AWS Lambda environment variables. Now that we have written the Dockerfile and the two lambda functions, let’s take a look at ...
Author aws-samples
Docker Hub
hub.docker.com › r › amazon › aws-lambda-nodejs
amazon/aws-lambda-nodejs - Docker Image
FROM public.ecr.aws/lambda/nodejs:12 # Copy function code COPY app.js ${LAMBDA_TASK_ROOT} # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) CMD [ "app.handler" ] Copy · You can then locally test your function using the docker build and docker run commands.
AWS re:Post
repost.aws › questions › QUuqiDRNZvTdSr7-TcZ_T4zw › why-is-my-aws-lambda-failing-with-no-module-named-templates-portada-cover-page-even-though-the-file-exists-in-my-container
Why is my AWS Lambda failing with “No module named ‘templates.portada.cover_page’” even though the file exists in my container? | AWS re:Post
April 21, 2025 - When using container images with ... default, it first searches the {LAMBDA_TASK_ROOT} directory, which is typically /var/task in the Lambda environment....