AWS Lambda is Unable to find app.handler (Custom Docker Image)


I want to deploy machine learning related code on AWS Lambda function as Docker image. Base Images provided by AWS for Python, don’t allow to install using apt-get command. So I created custom docker image for AWS Lambda. Below is the code of my Dockerfile.

ref: Create an image from an alternative base image

My Folder structure is as below:

When I run docker image, it shows error as below:

It seems it is unable to find /function directory but it is already there.


I’ve run into this thing recently and this is what works for me.

My dockerfile:

My entrypoint

Then I built my image with:

docker build –rm -t myimage .

And tested locally running with:

docker run -p 9000:8080 –rm -it myimage:latest

In another terminal I run:

curl -XPOST
“http://localhost:9000/2015-03-31/functions/function/invocations” -d
‘{“field1″:”..”, “field2″:”..”}’

Elaboration starts. My contain a method handler, which parse the argument event and retrieve the fields (you can see them in the curl call), then starts the elaboration. I set my workdir in /tmp because it’s the only read/write folder in AWS Lambda so I can put there some intermediate files of my elaboration.

Leave a Reply