Is it necessary to use Virtualenv in Docker?
I am currently developing a fullstack project using Django Restframework and React.
I have already made a working Dockerfile and a docker-compose.yml for both React and Django but none of my colleagues are using Docker instead they are only using pipenv.
I am thinking of implementing pipenv inside a Docker but is it necessary? and also which one is the best?
Top comments (5)
Docker is already a 'virtualization', so why use virtualenvs in it?
locally I use poetry (similar to pipenv but better imho): normally I generate a requirements.txt (with hashes) with poetry, pass it into container and then run pip install -r requirements.txt
EDIT: otherwise, if I remember well, you can pass to the container yaml also the pipfile.lock and then install dependencies, but, as said, I don't use pipenv
That is also what I am thinking, I am already passing requirements.txt to the container and pip installing it. But the thing is that I am the one who manages the package, I am the one who adds and removes packages from the requirements.txt.
Anyway thank you for your recommendation, I really appreciate it.
I would say you don't need a virtual env in your docker container.
What you can do is use the pipenv arguments --deploy and --system which should install the pipenv requirements into your docker container's base python.
I will look into that suggestion, thank you I really appreciate it. Also nice picture I love that movie.
There is a case with docker multistage build where you install packages in compile-image and then copy python virtual environment to builder-image in order to make final image smaller. I have venv example only.
EDIT: Found pipenv example - tech.zarmory.com/2018/09/docker-mu...