[Python] Activate python virtualenv in Dockerfile

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Dockerfile where I tried to activate python virtualenv so that, it should install all dependencies within this env. However, everything still gets installed globally. I used different approaches and none of them worked. I am also not getting any errors. Where is the problem?

    1. ENV PATH $PATH:env/bin

    2. ENV PATH $PATH:env/bin/activate

    3. RUN . env/bin/activate

    I also followed an example of a Dockerfile config for the python-runtime image on Google Cloud, which is basically the same stuff as above.


    Setting these environment variables are the same as running source /env/bin/activate.
    ​

    ENV VIRTUAL_ENV /env

    ENV PATH /env/bin:$PATH

    Additionally, what does ENV VIRTUAL_ENV /env mean and how it is used?

    Continue reading...

Compartilhe esta Página