amazon-web-services - 错误 : exec: \"app.handler\": executable file not found in $PATH", "errorType": "Runtime.InvalidEntrypoint"

标签 amazon-web-services docker lambda

我正在 Lambda 上测试我的代码,之前从未收到过此错误,并且在网上找不到任何解决方案。我为我的代码创建了一个 docker 镜像,因此这是我推送到 ECR 的 Docker 文件

FROM python:3.8

# Copy function code
COPY app.py ${LAMBDA_TASK_ROOT}

#Copy and install requirements
COPY requirements.txt ${LAMBDA_TASK_ROOT}
RUN pip install -r requirements.txt

ARG GITHUB_ACCESS_TOKEN
ARG TABLE_NAME
ARG AWS_ACCESS_KEY
ARG AWS_SECRET_KEY
ARG REGION

ENV GITHUB_ACCESS_TOKEN $GITHUB_ACCESS_TOKEN
ENV TABLE_NAME $TABLE_NAME
ENV AWS_ACCESS_KEY $AWS_ACCESS_KEY
ENV AWS_SECRET_KEY $AWS_SECRET_KEY
ENV REGION $REGION

# Set the CMD to the handler 
CMD [ "app.handler" ]

这也是我的 lambda 日志中显示的完整错误

START RequestId: d691e14e-349f-45c5-a4a7-b1b98a3e88be Version: $LATEST
IMAGE   Launch error: exec: "app.handler": executable file not found in $PATH   Entrypoint: []  Cmd: [app.handler]  WorkingDir: []IMAGE Launch error: exec: "app.handler": executable file not found in $PATH   Entrypoint: []  Cmd: [app.handler]  WorkingDir: []END RequestId: d691e14e-349f-45c5-a4a7-b1b98a3e88be
REPORT RequestId: d691e14e-349f-45c5-a4a7-b1b98a3e88be  Duration: 6.80 ms   Billed Duration: 7 ms   Memory Size: 128 MB Max Memory Used: 2 MB   
RequestId: d691e14e-349f-45c5-a4a7-b1b98a3e88be Error: exec: "app.handler": executable file not found in $PATH
Runtime.InvalidEntrypoint

最佳答案

Lambda 镜像不是由 python:3.8 Docker 镜像制作的。相反,它们应该由 public.ecr.aws/lambda/python:3.8 制成。 lambda 容器镜像必须专门构建才能与 lambda 正常工作。

AWS 文档详细解释了这一点:

关于amazon-web-services - 错误 : exec: \"app.handler\": executable file not found in $PATH", "errorType": "Runtime.InvalidEntrypoint",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72667058/

相关文章:

amazon-web-services - 作为一个实验,我想与 AWS 一起工作。我期望支付多少?

没有 docker pull 的 Docker 保存

C++ 11 避免 "Call Super"代码异味

c# - 如何将 Func<T,bool> 转换为 Expression<Func<T,bool>>

amazon-web-services - 如何使用 terraform 向 Elastic Beanstalk 环境创建的负载均衡器添加警报?

amazon-web-services - Amazon EFS 和 Docker - 创建镜像时出错

android/busybox/termux 测试环境

bash - 如何重新启动所有 docker 容器并在每次重新启动之间暂停?

c# - 从 lambda 表达式到用户定义类型的隐式转换

amazon-web-services - 无法使用AWS CodePipeline构建和部署Go Lambda-BundleType必须为YAML或JSON