I ran the following in Windows 10 Powershell and it worked
docker run -v ${pwd}:/var/task "amazon/aws-sam-cli-build-image-python3.8" /bin/sh -c "pip install -r requirements.txt -t python/lib/python3.8/site-packages; exit"
Answer from Scott on Stack OverflowDEV Community
dev.to › matthewvielkind › creating-python-aws-lambda-layers-with-docker-4376
Creating Python AWS Lambda Layers with Docker - DEV Community
May 25, 2020 - docker run -v "$PWD":/var/task "lambci/lambda:build-python3.8" /bin/sh -c "pip install -r requirements.txt -t python/lib/python3.8/site-packages/; exit" After running the command you should see the site-packages directory you created in the previous step populated with all your dependencies. If you have additional versions you want to create your Layer for make sure you substitute the occurrences of "python3.8" with the correct version you want to use.
Lambda Layers and CDK
Lambda layers is one of those features that _seem_ useful and turns out to be a nightmare in practice. Say for instance you keep your layers and functions using cloudformation. IaC, sane enough idea. layer L v1 is up. You deploy lambda A using it, all good and working. You update L so now it's v2. Next stack update for A has an issue, unrelated to the layer. Anything, random aws hiccup. The deployment rolls back. Ops, L v1 no longer exists, rollback failed, stack stuck.... Remove it all and do it again.... More on reddit.com
What's the fastest way to package requirements for a Lambda Function?
AWS SAM with sync. https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-sync.html More on reddit.com
Lambda with Python libraries
If you go with infrastructure as code, you can add the libraries you need as part of the CI/CD pipeline run, zipping the file at that point. This avoids polluting your Git repo with libraries. More on reddit.com
AWS Lambda: Package as Docker container or zip+Lambda layer?
Depends on your use case (shocking, I know). If you already have a build pipeline for docker images and you aren’t worried about the whole “images take longer durrr” FUD it makes sense to build images. They are easier for developers to reason about, use, maintain, etc. That being said, there are very likely performance gains to be had in choosing zip files over images. Otherwise there wouldn’t be so many posts/comments about it. More on reddit.com
Videos
03:59
How do I create a Lambda layer using a simulated Lambda environment ...
10:00
AWS Lambda with Docker Container Python + ECR Tutorial (Serverless ...
Building container-based AWS Lambda Functions in Python ...
12:16
Setup AWS Lambda Layers for Python using Docker - YouTube
17:38
AWS Lambda Layers Step by Step Tutorial | Python Libraries Management ...
AWS re:Post
repost.aws › knowledge-center › lambda-layer-simulated-docker
Create a Lambda layer using an ECR image and Docker | AWS re:Post
August 5, 2025 - Note: The total unzipped size of the function and all layers can't exceed the unzipped deployment package size limit of 250 MB. For information about Python version support in Lambda, see Building Lambda functions with Python. Run the following command once for each runtime that you specified in the directory structure: docker run -v "$PWD":/var/task "public.ecr.aws/sam/build-python3.x" /bin/sh -c "pip install -r requirements.txt -t python/; exit"
RandomWits
randomwits.com › blog › lambda-layer
Creating Python AWS lambda layer with Docker
February 21, 2022 - We will create a lambda layer my-lambda-layer. ... Next, we need to list libraries that we want to include in the lambda layer. For our example, we will only add pandas to our lambda layer. ... $ mkdir -p python/lib/python3.7/site-packages $ docker run \ -v "$(pwd):/var/task" \ "lambci/lambda:build-python3.7" \ /bin/sh -c "pip install -r requirements.txt \ -t python/lib/python3.7/site-packages/; exit"
AWS
aws.amazon.com › blogs › compute › working-with-lambda-layers-and-extensions-in-container-images
Working with Lambda layers and extensions in container images | Amazon Web Services
May 24, 2021 - Create separate Dockerfiles for the function and extension. The extension Dockerfile contains the following lines. FROM python:3.8-alpine AS installer #Layer Code COPY extensionssrc /opt/ COPY extensionssrc/requirements.txt /opt/ RUN pip install -r /opt/requirements.txt -t /opt/extensions/lib FROM scratch AS base WORKDIR /opt/extensions COPY --from=installer /opt/extensions .
Nesin
nesin.io › blog › aws-lambda-layer-python-dependencies
Create AWS Lambda Layer with Python 3 dependencies using Docker
January 4, 2024 - docker run -it -v $(pwd):/var/task --platform=linux/amd64 public.ecr.aws/sam/build-python3.10:1.106.0-20240104015600 · Now you can install the dependencies that you want. In my case, I'll just install OpenAI-related sdk ... That's pretty much it. To use the dependencies for your Lambda function, you need to add the upload layer.
Medium
ripon-banik.medium.com › convert-your-docker-image-to-aws-lambda-layers-5c8c685800db
Convert your docker image to AWS Lambda Layers | by Ripon Banik | Medium
November 16, 2021 - A good article to work with lambda layer is below. ... Basically you put the executable in /opt/bin and library under /opt based on the language used as per below (default) which can be changed by using environment variable in Lambda. Node.js — nodejs/node_modules, nodejs/node8/node_modules (NODE_PATH) ... xray-sdk.zip └ nodejs/node_modules/aws-xray-sdk Python — python, python/lib/python3.7/site-packages (site directories)
GitHub
github.com › developmentseed › geolambda
GitHub - developmentseed/geolambda: Create and deploy Geospatial AWS Lambda functions · GitHub
The Python Lambda Layer includes the libraries numpy, rasterio, GDAL, pyproj, and shapely. This is an addition to the standard GeoLambda layer; if you wish to use GeoLambda-Python, both layers must be included. ... The Docker images used to create the Lambda layer are also published to Docker Hub, and thus are also suitable for general use as a base image for geospatial applications.
Starred by 306 users
Forked by 84 users
Languages Dockerfile 68.0% | Shell 19.5% | Python 12.5%