Stop using virtualenv, pyenv, nvm, goenv and Use Docker images
Why I use Docker images
Using version managers like pyenv and nvm are obsolete.
For example, virtualenv/pyenv only encapsulates Python dependencies.
Docker containers encapsulate an entire OS with several dependencies.
Docker already allows to pull several one-click images like python, nodejs, golang, etc ...
docker pull python:3.9.0
# DockerfileFROM python:3.9.0
Docker images and containers
A Docker image includes the elements needed to run an application as a container -- such as code, config files, environment variables, libraries and run time.
A Docker container can be seen as a replica or as a printout of that image.
For example, you can have one python image and multiple containers related to this image.
Isolation with the OS (Clean Install)
You may not have python installed on your OS and you can pull the python 3.9 docker image.
So you can only use python inside a docker container.
docker pull python:3.9.0
You may have the python 2.7 installed on your OS and pull the python 3.9 docker image.
They will not conflict together, but you can only use python 3.9 inside a docker container.
If you don't want the python 3.9 anymore , you just have to delete the docker container related to the python 3.9 image and the python 3.9 image itself.
Multiple Versions
You can pull the python 2.7 docker image and the python 3.9 docker image.
They will not conflict together.
Multiple Layers
You can pull the python 2.9 docker image and install additional dependencies.
# DockerfileFROM python:3.9.0...COPY requirements.txt /app/requirements.txtRUN pip install -r requirements.txt
Upgrade - Switch versions
You can pull the python 3.8 docker image and then switch to the 3.9 image.
# DockerfileFROM python:3.8.0 -> FROM python:3.9.0
Example : python
# DockerfileFROM python:3.9.0
# DockerfileFROM python:3.9.0-alpine
Example : node
# DockerfileFROM node:14.16.0
# DockerfileFROM node:14.16.0-alpine
Hub
Links
Original Link: https://dev.to/javidjms/stop-using-virtualenv-pyenv-nvm-goenv-and-use-docker-images-40mn

Dev To

More About this Source Visit Dev To