Home > database >  AWS lambda container /bin/sh Error: Runtime exited without providing a reason"
AWS lambda container /bin/sh Error: Runtime exited without providing a reason"

Time:10-02

I have got this error from AWS lambda container Error: Runtime exited without providing a reason When I run this container locally, I have got exit code 0

But when I run this in Lambda I have got the error mentioned above and exit code 0.

In both cases, backup creates correctly on S3

My container runs this command:

FROM alpine:3.14.2

ARG BUILD_ID
ARG BUILD_DATE
ARG VERSION=0.0.9

LABEL maintainer="Rostyslav Malenko"
LABEL version="$VERSION"
LABEL description="This is custom Alpine Docker Image for the create SQL dump from RDS to S3 directly."
LABEL org.label-schema.build-date=$BUILD_DATE

ENV BUILD_ID=${BUILD_ID} \
    APPLICATION_VERSION=${VERSION} \
    SERVICE_ROLE=backup \
    NUMPROCS_WORKER=1 \
    INSTALL_PACKAGES="gzip mysql-client aws-cli" \
    WORKSD="/tmp"

RUN apk -v --update add --no-cache ${INSTALL_PACKAGES} && \
    rm -rf /var/cache/apk/* 

WORKDIR ${WORKSD}}

CMD /usr/bin/mysqldump --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} --port=3306 \
    --single-transaction \
    --routines \
    --triggers \
    --events \
    --add-drop-database \
    --opt \
    --add-locks \
    --compress \
    --databases ${DB_NAME} | gzip -9 | aws s3 cp - s3://${S3BUCKETNAME}/$(date  "%m-%d-%Y-%H-%M-%S")_${DB_NAME}.sql.gz ; echo $?

CodePudding user response:

AWS Lambda expects container images to implement a specific interface, so that the Lambda environment can pass the Lambda invocation event parameters into the container, and so that Lambda can properly parse the response.

You appear to be attempting to run a regular Docker image that does not implement the required AWS Lambda interface. Your use case actually looks like a better fit for AWS ECS Fargate. If you want to use Lambda you will need to modify your container or rebuild it using one of the provided AWS Lambda base container images.

  • Related