Problem starting Docker image as lambda function source

0

I am trying to use a container image as the source for a lambda, but am not able to start the container.

No matter what I set the CMD to, I get entrypoint requires the handler name to be the first argument

My Dockerfile looks something like:

FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt .
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.

Anyone have any thoughts?

Edited by: arogers on Jan 29, 2021 4:52 PM

arogers
질문됨 3년 전6104회 조회
3개 답변
0

arogers wrote:
I am trying to use a container image as the source for a lambda, but am not able to start the container.

No matter what I set the CMD to, I get entrypoint requires the handler name to be the first argument

My Dockerfile looks something like:

FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt .
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.

Anyone have any thoughts?

Edited by: arogers on Jan 29, 2021 4:52 PM
arogers wrote:
I am trying to use a container image as the source for a lambda, but am not able to start the container.

No matter what I set the CMD to, I get entrypoint requires the handler name to be the first argument

My Dockerfile looks something like:

FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt .
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.

Anyone have any thoughts?

Edited by: arogers on Jan 29, 2021 4:52 PM
arogers wrote:
I am trying to use a container image as the source for a lambda, but am not able to start the container.

No matter what I set the CMD to, I get entrypoint requires the handler name to be the first argument

My Dockerfile looks something like:

FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt .
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.

Anyone have any thoughts?

Edited by: arogers on Jan 29, 2021 4:52 PM
Hey arogers,

Here is what I have as a Dockerfile that is working for me, this may work for you too. However, I'm currently having issues with OpenCV.

FROM public.ecr.aws/lambda/python:3.8  
  
COPY requirements.txt ./  
  
RUN pip install --upgrade pip  
RUN pip install -r requirements.txt  
  
COPY . ./  
CMD \[ "app.handler" ]  

Edited by: samatvery on Feb 3, 2021 12:23 PM

Edited by: samatvery on Feb 3, 2021 12:23 PM

답변함 3년 전
0

Can you please try placing your app.handler inside quotes ["app.handler"] instead of keeping it without quotes [app.lambda_handler] ?
I believe docker needs between double quotes and it worked for me.

답변함 3년 전
0

Hi @samatvery, I tried customising the base image but it always fails, refer to my stackoverflow question here: https://stackoverflow.com/questions/66369212/aws-lambda-is-unable-to-find-app-handler-custom-docker-image

답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠