You should use yum package manager.

Here are the commands for installing tesseract on OpenSuse: https://tesseract-ocr.github.io/tessdoc/InstallationOpenSuse.html
add --nogpgcheck flag to skip key check.

Here is how your dockerfile should look like:

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

RUN yum install -y yum-utils

RUN yum-config-manager --add-repo https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/RHEL_7/
RUN yum update
RUN yum install -y tesseract --nogpgcheck
RUN yum install -y tesseract-langpack-heb --nogpgcheck



WORKDIR /code
COPY . .
COPY policy.xml /etc/ImageMagick-6
RUN yum install -y ghostscript


RUN pip install -r requirements.txt


EXPOSE 80
CMD ["app.lambda_handler"]
Answer from dina on Stack Overflow
🌐
Reddit
reddit.com › r/docker › working with aws lambda python from docker images - why is apt-get command missing?
r/docker on Reddit: Working with AWS Lambda Python from Docker images - why is apt-get command missing?
April 19, 2021 -

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

Discussions

amazon web services - How can I access the shell of the AWS Lambda images on ECR - Stack Overflow
While this was working for python3.7, this is breaking for python versions >3.7 as mentioned in this GitHub issue, which says its probably because python3.8 and higher don't have amazonlinux as base image. So I wanted to use the closest base image possible, and use public.ecr.aws/lambda/python:3.8. More on stackoverflow.com
🌐 stackoverflow.com
Working with AWS Lambda Python from Docker images - why is apt-get command missing?
I didn't look at the Dockerfile but is this built on alpine? Because that doesn't have apt. Edit: it's Amazon Linux. So it's yum, not apt. More on reddit.com
🌐 r/aws
4
1
April 19, 2021
docker - Install poppler in AWS base python image for Lambda - Stack Overflow
I am trying to deploy my docker container on AWS Lambda. However, I use pdf2image package in my code which depends on poppler. To install poppler, I need to insert the following line in the Dockerf... More on stackoverflow.com
🌐 stackoverflow.com
January 24, 2022
Lambda Python Dockerfile Yum
I think it's AWS linux 2 base image that all their lambda images are built on changed. I believe we have to use APK now. I just pulled the latest amazonlinux2 image and confirmed it does not have yum and does have apk. More on reddit.com
🌐 r/aws
5
5
December 5, 2023
🌐
Stack Overflow
stackoverflow.com › questions › 75171865 › running-apt-get-in-aws-lambda
python - Running apt-get in aws lambda - Stack Overflow
Here's a simple example of a Python application executed in a container: https://docs.aws.amazon.com/lambda/latest/dg/python-image.html · Dockerfile: FROM public.ecr.aws/lambda/python:3.8 # Install the function's dependencies using file requirements.txt # from your project folder.
🌐
ECR Public Gallery
gallery.ecr.aws › lambda
AWS Lambda - Amazon ECR Public Gallery
Amazon ECR Public Gallery is a website that allows anyone to browse and search for public container images, view developer-provided details, and see pull commands
🌐
ECR Public Gallery
gallery.ecr.aws › lambda › python
Amazon ECR Public Gallery - AWS Lambda/python
These base images contain the Amazon Linux Base operating system, the runtime for a given language, dependencies and the Lambda Runtime Interface Client (RIC), which implements the Lambda Runtime API. The Lambda Runtime Interface Client allows your runtime to receive requests from and send requests to the Lambda service. To learn more about the composition of the base images you can visit https://github.com/aws/aws-lambda-base-images.
🌐
PyPI
pypi.org › project › awslambdaric
awslambdaric · PyPI
# Define custom function directory ... ARG FUNCTION_DIR # Install aws-lambda-cpp build dependencies RUN apt-get update && \ apt-get install -y \ g++ \ make ......
🌐
Reddit
reddit.com › r/aws › working with aws lambda python from docker images - why is apt-get command missing?
r/aws on Reddit: Working with AWS Lambda Python from Docker images - why is apt-get command missing?
April 19, 2021 -

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 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

Find elsewhere
🌐
ECR Public Gallery
gallery.ecr.aws › e9j1g0y4 › lambda-python-3.11
lambda-python-3.11 - Amazon ECR Public Gallery
Amazon ECR Public Gallery is a website that allows anyone to browse and search for public container images, view developer-provided details, and see pull commands
🌐
Reddit
reddit.com › r/aws › lambda python dockerfile yum
r/aws on Reddit: Lambda Python Dockerfile Yum
December 5, 2023 -

Hi, 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?

🌐
AWS re:Post
repost.aws › questions › QUEgw2bC3aTV2hmssdD5bYfA › how-to-use-a-public-ecr-with-aws-lambda
How to use a public ECR with AWS Lambda? | AWS re:Post
October 17, 2023 - When using containers to deploy AWS Lambda functions, the container image must reside in Amazon ECR. Amazon ECR Public and other repositories are not supported.
🌐
ECR Public Gallery
gallery.ecr.aws › w2s0h5h2 › lambda-python
w2s0h5h2/lambda-python - Amazon ECR Public Gallery
Amazon ECR Public Gallery is a website that allows anyone to browse and search for public container images, view developer-provided details, and see pull commands
🌐
DEV Community
dev.to › shilleh › how-to-install-pip-packages-in-aws-lambda-using-docker-and-ecr-2ghh
How to Install Pip Packages in AWS Lambda Using Docker and ECR - DEV Community
May 24, 2024 - In this blog, we will walk through how to install pip packages in Lambda packages using Docker and ECR. AWS Lambda is a powerful service that allows you to run code without provisioning or managing servers. However, managing dependencies for your Lambda functions can be challenging, especially when dealing with complex Python packages.
🌐
Docker Hub
hub.docker.com › r › amazon › aws-lambda-python
amazon/aws-lambda-python - Docker Image
FROM public.ecr.aws/lambda/python:3.8 # Copy function code COPY app.py ${LAMBDA_TASK_ROOT} # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) CMD [ "app.handler" ] Copy · You can then locally test your function using the docker build and docker run commands.
🌐
GitHub
github.com › aws › aws-lambda-base-images › issues › 128
Yum Not Available in Python 3.11 Image · Issue #128 · aws/aws-lambda-base-images
December 5, 2023 - Yum is not available in the latest Python 3.11 image, public.ecr.aws/lambda/python:3.11.2023.12.05.16.
Author: aws
🌐
GitHub
raw.githubusercontent.com › yike5460 › LambdaContainerApp › main › dockerfile-custom-tesseract
https://raw.githubusercontent.com/yike5460/LambdaC...
RUN curl $(aws lambda get-layer-version-by-arn --arn arn:aws-cn:lambda:cn-northwest-1:123456789012:layer:pythonlibs-layer:1 --query 'Content.Location' --output text) --output tesseract-layer.zip · RUN unzip tesseract-layer.zip -d ${LAYER_DIR} RUN rm tesseract-layer.zip · FROM public.ecr.aws/bitnami/python:3.7 · ARG LAYER_DIR · WORKDIR ${LAYERDIR} COPY --from=build-image ${LAYERDIR} . COPY app.py . RUN apt-get update && apt-get install -y libpng-dev libjpeg62 libtiff5 ·
🌐
Stack Overflow
stackoverflow.com › questions › 73448829 › install-package-with-conda-on-aws-ecr-and-run-it-with-lambda
python - Install package with Conda on AWS ECR and run it with Lambda - Stack Overflow
I created an image with Docker and push it to AWS ECR. Then I will run the image with Lambda. This is my Dockerfile · FROM ubuntu:18.04 ENV PATH="/root/miniconda3/bin:${PATH}" ARG PATH="/root/miniconda3/bin:${PATH}" RUN apt-get update RUN apt-get install -y wget && rm -rf /var/lib/apt/lists/* RUN wget \ https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ && mkdir /root/.conda \ && bash Miniconda3-latest-Linux-x86_64.sh -b RUN conda create -n top2vec python=3.9 RUN conda install -c conda-forge hdbscan COPY requirements.txt ./ RUN python3.9 -m pip install -r requirements.txt COPY app.py ./ CMD ["app.lambda_handler"] The build is successful, but when I run it on Lambda.
🌐
ECR Public Gallery
gallery.ecr.aws › ubuntu › python
Ubuntu/python - Amazon ECR Public Gallery
Amazon ECR Public Gallery is a website that allows anyone to browse and search for public container images, view developer-provided details, and see pull commands