loading...

Virtualenv(pipenv) in Docker?

github logo ・1 min read

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?

Thank you...

twitter logo DISCUSS (4)
markdown guide
 

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

 

Docker is already a 'virtualization', so why use virtualenvs in it?

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.

Classic DEV Post from Aug 4 '19

You're not worth hiring unless...

Jaako profile image
I am enjoying life. Am I?

dev.to is where software developers stay in the loop and avoid career stagnation.

Sign up (for free)