Skip to content

Impossible to RUN LAMBDA images when Python <3.7  #40

Open
@massimo-camplani-kidsloop

Description

This it has been partially discussed also in another issue, see link at bottom of the message. But I think this is capturing a wider problem I am finding with the base images

I have stripped down my docker file and my code, so that they do not contains any dependencies or anything particular. This following the very basic example in here

https://docs.aws.amazon.com/lambda/latest/dg/python-image.html
https://docs.aws.amazon.com/lambda/latest/dg/images-test.html#images-test-AWSbase

Docker files is this one

FROM public.ecr.aws/lambda/python:3.7
COPY app/app.py "${LAMBDA_TASK_ROOT}/"
CMD [ "app.handler" ]

Assuming your code is in a subfolder called 'app' and the filename is app.py

def handler(event, context):
    print("Some Interesting Printing")
    return False

if __name__ == "__main__":
    output = handler(False, False)
    print(output)

Now, you can build the image (lets call it mylambda)

docker build -t mylambda:latest .

If you interactively use the container as below

docker run -it --rm --entrypoint /bin/bash --name testlambda mylambda:latest
You can run your app.py script with no issues.

However, if you deploy the image in Lambda itself or run locally as in the example here https://docs.aws.amazon.com/lambda/latest/dg/images-test.html#images-test-AWSbase

docker run -p 9000:8080 mylambda:latest

and then curl some message

curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'

The results I am getting is a glibc compatibility as shown below. Note that this does not happen if in the Docker file the 3.8 image is used FROM public.ecr.aws/lambda/python:3.8

Screenshot 2022-03-16 at 13 56 07

For some compatibility issues, I need to build my app with python 3.7

Previous issue
#23

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions