- Newest
- Most votes
- Most comments
Hello.
As stated in the automated response from re:Post Agent, it is possible to avoid the error by implementing CI/CD or using EC2.
Also, if the container image is not too large, it can be built using CloudShell.
I think that with CloudShell you can build container images without being affected by the CPU architecture.
However, if your container image is large, it may be better to build it using EC2 or similar.
https://docs.aws.amazon.com/cloudshell/latest/userguide/tutorial-docker-cli.html
By the way, have you tried the "--provenance=false" option as mentioned in the Stackoverflow answer?
https://stackoverflow.com/questions/65608802/cant-deploy-container-image-to-lambda-function
docker build --provenance=false -t batch-demo-lambda .
The issue you're experiencing is indeed related to building Docker images on Apple Silicon (M1/M2) Macs for use with AWS Lambda. This is a known compatibility problem that many developers have encountered.
When you build a Docker image on an M1/M2 Mac, it creates an ARM64 architecture image by default. However, AWS Lambda typically expects x86_64 architecture images, which is why you're encountering the error when trying to use your locally built image.
There are a few ways to address this issue:
-
Use Docker's buildx feature to create multi-architecture images: Instead of building your image normally, you can use Docker's buildx command to create an image that works on both ARM and x86 architectures. Here's an example command:
docker buildx build --platform linux/amd64 -t your-image-name .This will create an x86_64 compatible image even when building on an M1/M2 Mac.
-
Specify the platform when building: You can explicitly specify the platform when building your Docker image:
docker build --platform linux/amd64 -t your-image-name . -
Use a CI/CD pipeline: If you're working on a team or need a more robust solution, consider setting up a CI/CD pipeline (e.g., GitHub Actions, GitLab CI, or AWS CodeBuild) to build your Docker images on x86_64 machines.
-
Use AWS Cloud9 or EC2: You could use an AWS Cloud9 environment or launch an EC2 instance to build your Docker images in an x86_64 environment.
After building the image using one of these methods, push it to ECR, and it should work correctly with Lambda.
Remember to ensure that your Dockerfile is set up correctly for Lambda, including using a compatible base image and setting up the necessary runtime interface clients.
By using one of these approaches, you should be able to create Docker images on your M1/M2 Mac that are compatible with AWS Lambda, without needing to use a VM or rely on a friend with a different system.
Sources
Getting a "SINGLE_BUILD_CONTAINER_DEAD" error with a custom Docker image | AWS re:Post
Lambda with Docker (from ECR) is Failing to Install All Depedencies | AWS re:Post
I followed all the steps this LLM Amazon Q response offered above through Step 2 — it still did not work when trying to attach the uploaded container to the AWS Lambda function. I guess I will have to try a CI/CD pipeline, like AWS CodeBuild, or try building the Docker Image on an AWS EC2 or Cloud9. Oh well...
Relevant content
- asked 8 months ago

That did it! A combination of using the flags for the build,
--platform linux/amd64 --provenance=falsein the Docker build command built the Docker Image correctly, it uploaded a-okay to my AWS ECR, and... I attached it to the AWS Lambda function successfully! Huzzah! Yay! 5 ⭐️'s. Perfect! No notes. My littel test Node.JS app is now running a-okay there (though I'll be taking it down soon as not to be charged much more, this was just a test for the tutorial. Thank you aos much @Riku Kobayashi. You were most helpful. And thank you for the links to the AWS Guide to building the Docker Image and the Stackoverflow article on using the--provenance=false. I've bookmarked both of them. One question — is there an article here on AWS re:Post somewhere about using these Docker build switches or CloudShell or Cloud9 or an EC2 w/ Docker to build Docker Images when you're building on an Apple Macintosh with the Apple Silicon M* Series chips? That would have been especially helpful in this case, but I couldn't find anything before finding my article. I tried searching here in AWS re:Post with "AWS ECR Docker Container Build AWS Lambda Apple Silicon," and it returned pages and pages of stuff that had nothing to do with Macs with Apple Silicon chips, whatsoever. Had my eyes spinning. 😵💫 But thank you, so much, for the help, again.I'm glad your problem seems to have been resolved.
I also searched for it, but I couldn't find any such article in AWS re:Post.
I created an article with tips. https://repost.aws/articles/ARnjMtSZIySZWAAo9mC85SIQ
Hooray!! Thank you so much for the article! 👏 👏 👏