Bests practices around docker and python environment

I’m a newbie on Docker, and I’ll have to host multiple application on several containers in my work. What I wanted to know is : should I create a virtual environment for each container (with only the python library needed for the API created for example) or should I create one big virtual environment that I’ll have to install on every container ? Or is it possible that one container host multiples application ?
I tried to find some of the bests practices around this, but couldn’t find something very clear.

In advance, thank you.


The point of a container is having a little as possible pr image.
So if you have an application that only needs 10 modules, then you should only install those 10 modules.

Just in case you havnt noticed, the offcial python image on Docker Hub

have an example of using requirements in a dockerfile:

FROM python:3

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "./" ]

Thank you for your answer!
I chose your type of solution, but still I have an other constraint. The image needs to be a lightweight windows image. I found windows nanoserver, but my project needs to be connected to MSSQL and it’s not possible to install ODBC drivers on it.

Do you know any other windows image small than 2go on which I could to this?

No sorry, i dont know such image :slightly_smiling_face:
Not saying that they dont exist! I just dont know any :wink:

1 Like

No problem. Just continuing my researches!
Thank you very much anyway :grinning: