Skip to content
Advertisement

Why do people create virtualenv in a docker container?

You can build a container with Dockerfile in a few seconds. Then why do people need to install a virtual enviroment inside the docker container?

It’s like a “virtual machine” in a virtual machine ?

Advertisement

Answer

I am working with virtualenvs in Docker and I think there are several reasons:

  1. you may want to isolate your app from system’s python packages
  2. you may want to run a custom version of python but still keep the system’s packages untouched
  3. you may need fine grain control on the packages installed for a specific app
  4. you may need to run multiple apps with different requirements

I think these are all reasonably good reasons to add a little pip install virtualenv at the end of the installation! :)

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement