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?
2
Answers
The python:3.9 image is based on the
debian:bullseye
image, so you can use apt to install tesseract like thisAs 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.
Another way is to load the required
.tar
files, that you need to install specific package, or just use precompilied binary.as you can see in documentation, they have binaries for ubuntu, debian and windows – (load here, for ubuntu docker image).
You can call them straight from supported python library or command line.
Also you should ensure to provide required language data (add those files in dockerfile), if required.