Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lambda container images complain about entrypoint needing handler name as the first argument

When I run an AWS Lambda container (Docker) image, for example:

docker run public.ecr.aws/lambda/java bash

I get the following error:

entrypoint requires the handler name to be the first argument

What should the handler name be?

like image 652
bjfletcher Avatar asked Dec 02 '20 11:12

bjfletcher


People also ask

What is Lambda entrypoint?

/lambda-entrypoint.sh is inherited from the base image (ie. public. ecr. aws/lambda/{runtime} ) and is set as the ENTRYPOINT in order to detect whether the image is being run in Lambda or not, to decide whether to invoke the function through the Runtime Interface Emulator or directly if running in Lambda cloud.

What is Lambda container image?

A Lambda container image is a package that includes the Lambda Runtime API, necessary dependencies, an operating system, and function handlers required to run Docker containers in AWS Lambda. These packages allow development teams to deploy and execute arbitrary code and libraries into the Lambda runtime.

What is the difference between entrypoint and CMD in Docker?

Differences between CMD & ENTRYPOINT CMD commands are ignored by Daemon when there are parameters stated within the docker run command while ENTRYPOINT instructions are not ignored but instead are appended as command line parameters by treating those as arguments of the command.


1 Answers

It depends what the language is of the runtime. For example, if it is NodeJS, then the handler name should look like:

"app.handler"

If it is Java, then it should look like:

"com.example.LambdaHandler::handleRequest"

The image will look for them in LAMBDA_TASK_ROOT so you will need to make sure that your code (or compiled code) is copied to that folder when you build the image, for example:

COPY target/* ${LAMBDA_TASK_ROOT}
like image 170
bjfletcher Avatar answered Sep 21 '22 22:09

bjfletcher