I built a Docker Lambda Image using the following DockerFile
FROM registry.access.redhat.com/ubi8/ubi:8.1 as base
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
RUN yum update -y
RUN yum install -y sudo bash curl wget man-db nano bash-completion
RUN yum install -y java-11-openjdk-devel
RUN java -version
ENTRYPOINT [ "/usr/bin/java", "-cp", "./*", "com.amazonaws.services.lambda.runtime.api.client.AWSLambda" ]
CMD ["optimizerMarsExecutor.OptimizerMarsExecutorFunction::handleRequest"]
After building and tagging the image, I executed the Lambda function with the following commands
docker run -p 9000:8080 mars-console-linux-image
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'
Following the executiong of the commands above, I received the following errors:
Error: Could not find or load main class com.amazonaws.services.lambda.runtime.api.client.AWSLambda
Caused by: java.lang.ClassNotFoundException: com.amazonaws.services.lambda.runtime.api.client.AWSLambda
What am I missing?
2
Answers
I suspect you’re not installing the Runtime Interface Client.
See this example from AWS.
There’s a
pom.xml
in the local folder that’s copied to the container image (ADD pom.xml .
) before Maven is run (RUN mvn ...
) to install the dependencies defined in thepom.xml
file:Try replicating the example in that document and you should be successful.
I think the issue is with how your building the image.