Activate python virtualenv in Dockerfile

后端 未结 6 1836
忘了有多久
忘了有多久 2020-12-05 02:04

I have a Dockerfile where I try to activate python virtualenv after what, it should install all dependencies within this env. However, everything still gets installed global

6条回答
  •  再見小時候
    2020-12-05 02:51

    If you your using python 3.x :

    RUN pip install virtualenv
    RUN virtualenv -p python3.5 virtual
    RUN /bin/bash -c "source /virtual/bin/activate"
    

    If you are using python 2.x :

    RUN pip install virtualenv
    RUN virtualenv virtual
    RUN /bin/bash -c "source /virtual/bin/activate"
    

提交回复
热议问题