By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Cannot deploy docker container to Lambda

0

Here is the error message:

The image manifest or layer media type for the source image 12345678910.dkr.ecr.us-west-1.amazonaws.com/repo1@sha256:#### is not supported.

I have docker desktop installed v4.35.1 on Windows with WSL installed: Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy

The docker file:

FROM public.ecr.aws/lambda/python:3.12.2024.11.11.15-x86_64

# Install the chrome dependencies
RUN dnf install -y atk cups-libs gtk3 libXcomposite alsa-lib \
libXcursor libXdamage libXext libXi libXrandr libXScrnSaver \
libXtst pango at-spi2-atk libXt xorg-x11-server-Xvfb \
xorg-x11-xauth dbus-glib dbus-glib-devel nss mesa-libgbm jq unzip

# Copy and run the chorme installer
COPY ./chrome-installer.sh ./chrome-installer.sh
RUN chmod +x ./chrome-installer.sh
RUN ./chrome-installer.sh
RUN rm ./chrome-installer.sh

# Install python dependencies
RUN pip3 install --upgrade pip
RUN pip3 install 'awswrangler[modin]'==3.10.0 'awswrangler[ray]'==3.10.0 notion-client selenium

# Copy the script
COPY query.txt ./
COPY UseEntry.py ./

# Run the Lambda in the python file
CMD [ "UseEntry.lambda_handler"]

I have followed every single AWS doc, stackoverflow, youtube video, and more to try and get this thing to deploy. I don't get exactly what the issue is.

Yes, the local docker container seems to work without issue. It's just a problem when I attempt to use it in Lambda. I have tried to deploy this for the last several hours.

asked a month ago116 views
1 Answer
0

It appears you're encountering an issue with deploying a Docker container to AWS Lambda. The error message suggests that there's a problem with the image manifest or layer media type. This can occur due to incompatibility between the Docker image format and what Lambda expects. Let's go through some potential solutions:

  1. Ensure you're using a Lambda-compatible base image. Your Dockerfile starts with a Lambda-specific base image, which is good. However, make sure you're using the most up-to-date version compatible with Lambda.

  2. Check that you're building the image for the correct architecture. Lambda functions run on x86_64 architecture, so ensure your image is built for this architecture.

  3. Verify that you're using a supported Docker version. Some older Docker versions may produce image formats that are not compatible with Lambda. Make sure you're using a recent version of Docker.

  4. When pushing your image to ECR, make sure you're using the ':latest' tag or a specific version tag, not the SHA256 digest.

  5. Try rebuilding your image without any custom layers or with minimal customization to isolate the issue.

  6. Ensure that your ECR repository is in the same region as where you're trying to create the Lambda function.

  7. Double-check that you have the necessary permissions to pull the image from ECR and create Lambda functions.

  8. Try using the AWS CLI to create the Lambda function instead of the console, as it might provide more detailed error messages.

If the issue persists after trying these steps, you may need to simplify your Dockerfile and gradually add components back in to identify which specific part is causing the compatibility issue. It's also worth noting that some of the packages you're installing (like Chrome and X11 libraries) are quite large and may not be typically used in Lambda environments, which could potentially cause issues.

Remember to clean up your ECR repository and remove any problematic images before pushing new versions.
Sources
AWS Lambda now supports container images as a packaging format
Deploy Lambda functions with container images - AWS Prescriptive Guidance
Deploy Go Lambda functions with container images - AWS Lambda
Deploy Ruby Lambda functions with container images - AWS Lambda

profile picture
answered a month ago
profile pictureAWS
SUPPORT ENGINEER
reviewed 25 days ago
  • I have tried everything the AI has suggested. I suppose the other option is to do this in a fargate task.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions