Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why people create virtualenv in a docker container?

Tags:

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 ?

like image 394
Liao Zhuodi Avatar asked Mar 19 '15 14:03

Liao Zhuodi


People also ask

Should I use virtual environment in Docker container?

While Docker provides an isolated environment for your Python application, you're better off by using virtualenv (or your tool of choice) nevertheless. It can help you to maintain control over your Python environment & dependencies.

What is the purpose of virtualenv?

virtualenv is a tool for creating isolated Python environments containing their own copy of python , pip , and their own place to keep libraries installed from PyPI. It's designed to allow you to work on multiple projects with different dependencies at the same time on the same machine.

Is a Docker container a virtual environment?

Docker is popular virtualization software that helps its users in developing, deploying, monitoring, and running applications in a Docker Container with all their dependencies.

What are some advantages of Docker container over virtual machines?

Advantages of Docker Containers Docker containers are process-isolated and don't require a hardware hypervisor. This means Docker containers are much smaller and require far fewer resources than a VM. Docker is fast. Very fast.


1 Answers

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! :)

like image 188
gru Avatar answered Oct 11 '22 01:10

gru