AWS Lambda: Package as Docker container or zip+Lambda layer?
Struggling to Deploy Docker Image to AWS Lambda: Image Manifest Issues
Videos
The traditional way of packaging Lambda function is to simply zip it up and upload it for running. If the dependencies are big, then zip them up as a Lambda layer if needed.
However, now Lambda function can also be packaged as a Docker container with all he required dependencies.
How do we choose between them? Are they better for one situation or another?
Hi everyone,
I'm trying to deploy a Docker container to AWS Lambda, but I keep running into issues with the image manifest format. Specifically, I receive the error:
"The image manifest or layer media type for the source image is not supported."
What I've Done So Far
-
Dockerfile Setup: My
Dockerfileuses the AWS Lambda Python 3.12 base image:FROM COPY requirements.txt . RUN pip install -r requirements.txt -t /var/task COPY /var/task CMD ["main.lambda_handler"] public.ecr.aws/lambda/python:3.12main.py -
Build and Push Process:
-
I built the image using:docker buildx build --platform linux/amd64 -t marketdatafetcher:latest . docker tag marketdatafetcher:latest 585768148898.dkr.ecr.eu-north-1.amazonaws.com/marketdatafetcher:latest docker push 585768148898.dkr.ecr.eu-north-1.amazonaws.com/marketdatafetcher:latest
-
Checked the pushed image in ECR, and the manifest type is
application/vnd.oci.image.index.v1+json.
-
-
Tried Docker Save and Reload: I attempted to re-save the image to convert the manifest:However, the manifest remains as
application/vnd.oci.image.index.v1+json.docker save marketdatafetcher:latest -o marketdatafetcher.tar docker load -i marketdatafetcher.tar docker tag marketdatafetcher:latest docker push 585768148898.dkr.ecr.eu-north-1.amazonaws.com/marketdatafetcher:latest585768148898.dkr.ecr.eu-north-1.amazonaws.com/marketdatafetcher:latest -
Environment Details:
-
Docker Version: 27.4.0 on Windows with Docker Desktop.
-
AWS CLI and IAM setup are configured correctly.
-
Using
aws ecrto manage the repository.
-
-
Validation:
-
I can inspect the manifest using
docker manifest inspect. -
Despite following recommendations to re-tag and push, the manifest type does not change to the required
application/vnd.docker.distribution.manifest.v2+json.
-
What I Need Help With
-
How can I force Docker to produce a compatible manifest (
v2format) for AWS Lambda? -
Are there alternative approaches or tools I should try to fix this issue?
-
Has anyone successfully deployed a container with a similar setup and can share their steps?
Any guidance or suggestions would be greatly appreciated! Thank you in advance for your help! 😊