38

I try to deploy container image to lambda function, but this error message appear

The image manifest or layer media type for the source image <image_source> is not supported.

here is my Dockerfile, i believe i have use the proper setup

FROM public.ecr.aws/lambda/python:3.8

# Install dependencies
COPY requirements.txt ./
RUN pip install -r requirements.txt

# Copy function code
COPY app/* ./

# Set the CMD to your handler
CMD [ "lambda_function.lambda_handler" ]
4
  • Where exactly does this error occur? Commented Jan 7, 2021 at 8:45
  • When creating lambda function, after specifying the container image, A red box with the message appear @Marcin Commented Jan 7, 2021 at 8:59
  • @Bramanta take a look at this official blog post which has an exact example of the python docker image packing, it worked for me. Commented Jan 7, 2021 at 9:01
  • What's in your app/ folder? Commented Jan 7, 2021 at 10:41

5 Answers 5

58

If you are using buildx >= 0.10 specifying target platform does not work since it also creates multi-platform index by default.

To fix this problem set --provenance=false to docker build.

For more details please see: https://github.com/docker/buildx/issues/1509#issuecomment-1378538197

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! This fixed our issue. We use buildkit to build docker images for AWS Lambda hosted on AWS ECR. Our deployments started failing recently with error: "Resource handler returned message: "The image manifest or layer media type for the source image *.dkr.ecr.*.amazonaws.com/*:* is not supported. (Service: Lambda, Status Code: 400...)"
solved it for me
14

I encountered the same problem, building a linux/amd64 image following the official AWS tutorial.

I finally succeeded to create a (working) lambda function using the one of the 3 images published in the ECR repro : not the one with the tag mentionned in the "docker push" command, not the one with size 0 but the 3rd one using its hash tag.

I don't know why the "docker push" command generate 3 images in the ECR repo ! and why the image tagged in the "docker push" command is not working...

6 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
its been almost 4 years and this is the correct answer. Why can't AWS update their documentation. This is the 3rd AWS resource I've run into some weird problem where the "hello world" examples don't work. this breaks customer trust and stops adoption. Its almost like no one is actually testing the documentation that they write (or that the people testing are too knowledgeable and aren't actually following the written instructions).
This worked for me as well. I went into the console, went to Elastic Container Registry, clicked the repository of interest, and then clicked "Copy URI" next to the non-latest one, with type "Image" instead of "Image Index". Pasting this URI into the command worked as intended.
Worked for me. It's very strange.
This worked for me.
|
11

Try by specifying the target platform of the image you build as amd64:

docker build --platform linux/amd64 . -t my_image.

I get the same error while trying to deploy a lambda based on an image that supports both linux/amd64 and linux/arm64/v8 (Apple Silicon) architectures.

3 Comments

Yes, ECR supports multi-arch images but lambda don't seem to handle them.
I believe lambda does handle them, but you need to make that decision when you create/configure the lambda. AWS will expect the build to target the CPU architecture you told it.
Thanks for this comment my issue was the platform flag. My old Mac was using --platform linux/arm64 while silicon Mac needed that to be linux/arm64/v8. I didn't know that until this comment. But still don't know why the tagged image doesn't work but the unwanted extra image uploaded works
6

Ran into the same issue on an Apple Silicon MacBook. Pass both --platform linux/amd64 and --provenance=false.

Comments

3

I fought with this for hours. Finally pieced together a couple of key elements from other threads... On my Silicon process Macbook, I was ONLY able to get this to work by passing BOTH the --platform and --provenance switches to the docker build command.

You'll need to replace "lambda-images" in this command with the name of your repository and be sure to replace "us-east-2" with the region you are using.

Example command:

docker build -f Dockerfile \
     --platform linux/amd64 \
     --provenance=false \
    -t 1234567890.dkr.ecr.us-east-2.amazonaws.com/lambda-images:latest \
    .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.