I have a Python application that I want to containerise with Docker. I'm using a Dockerfile such as:
FROM python:3.9
WORKDIR /app
COPY myapp ./myapp
COPY requires.txt .
RUN pip install --no-cache-dir -r requires.txt
Now, my problem is that I have to install certain dependencies that are not just Python packages, for example tesseract.
How do I install this in the built image? Is the python:3.9 image built on top an OS, such as Ubuntu, where I can add software? If so, how? Or does it make more sense to start with a proper OS image, let's say debian por instance, and from there install tesseract and Python (using RUN apt-get ...), and then using python -m pip ... to fulfill the Python of dependences?
CodePudding user response:
The python:3.9 image is based on the debian:bullseye image, so you can use apt to install tesseract like this
FROM python:3.9
RUN apt update && apt install -y tesseract-ocr
WORKDIR /app
COPY myapp ./myapp
COPY requires.txt .
RUN pip install --no-cache-dir -r requires.txt
As for starting from a base OS image or from a python image, I always try to get as much for free as I can and use the image that I have to modify the least.
CodePudding user response:
Please read this article for the best python-based images
