Lambda Python Dockerfile Yum
AWS Lambda: Package as Docker container or zip+Lambda layer?
Working with AWS Lambda Python from Docker images - why is apt-get command missing?
End-to-End Tutorial on Combining AWS Lambda, Docker, and Python
AWS Lambda recently added support for Docker images with Python, where before you had to zip all your code and dependencies. With this update I wanted to make a full length tutorial to cover everything necessary to be productive.
The playlist is broken into six parts:
-
An introduction to the app that will be built and the various AWS components that will be used
-
Cloning the GitHub repo and doing necessary setup to test the application locally
-
Creating a Docker image of the Python script and running it on AWS Lambda, while also showing how painful it is to do even minor updates
-
Adding CI/CD with GitHub Actions to speed up code updates
-
Adding AWS Cloudwatch to create a cron job that schedules the Lambda function to run on periodic intervals
-
Walking through an AWS Cloudformation yaml template that will create the Lambda function and Cloudwatch rule automatically and covering all the benefits of using a Cloudformation template
This tutorial truly is end-to-end. If you enjoy the content, you can help me a ton by doing any or all of the following:
-
supporting me on Patreon
-
subscribing to my YouTube channel
-
liking and/or commenting on the video
-
sharing the video or channel on any platform (reddit, twitter, discord, etc.)
-
starring the GitHub repo
-
following me on GitHub
Any questions or requests, just leave a comment.
More on reddit.comHi, I've been creating some code and uploading it using a Dockerfile image into AWS ECR. Then I load the image onto AWS Lambda where I run the code.
My docker file starts like this:
Start with the base image
FROM public.ecr.aws/lambda/python:3.11 as build
Install system-level dependencies for Chrome and FFmpeg
RUN yum install -y unzip atk cups-libs gtk3 libXcomposite alsa-lib \
I've been using this docker file with docker build and uploading it for weeks now without any issue. Today when I did docker build I got this error:
=> ERROR [ 2/16] RUN yum install -y unzip atk cups-libs gtk3 libXcomposite alsa-lib ERROR: failed to solve: process "/bin/sh -c yum install -y unzip atk cups-libs gtk3 libXcomposite alsa-lib
Which I thought could be the base image, that did not have yum installed. But it is the same 3.11 as previous days.
Any idea or solutions to this? Do you guys know if the base image python:3.11 has changed in any way recently?
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,
I'm trying to setup a Python lambda function that requires Pytorch. Apparently one of the code's dependencies is using libgl1-mesa-glx
In the Dockerfile I tried to add
RUN apt-get update && apt-get install libgl1-mesa-glx
But when building the Docker image it tells me it's missing the apt-get command. I tried also with aptitude and apt, but still nothing.
I'm building the Docker image public.ecr.aws/lambda/python:3.8 https://github.com/aws/aws-lambda-base-images/blob/python3.8/Dockerfile.python3.8 which is built FROM scratch as I can tell.
What can I do to solve this? Why is apt-get command missing and is there an alternative way to install the libgl1-mesa-glx stuff?
thanks