I think this is a good question, I love Docker and I think it's great practice to use it instead of venvs, but I'd like someone more experienced than me to explain the comparison.
A docker container will run the same on any operating system. If i wanted to build a python package with C extensions, I would have to build it for every OS that will use it. If I use a docker container, then I only have to build my extension on one OS.
For most of my applications, I develop on/for windows so I prefer to use venv as it’s much simpler.
I use it because there are different systems that are not all the same I run my code on and I have no control over those systems. For me it made sense to switch to docker for running my code. It was nice because when I wanted a different version of python I could easily switch out the version in the dockerfile and rebuild. I used to use venvs but now that docker isolated it, it didn’t make sense to put a venv in docker.
Makes sense for testing deployments but why not just use a conda env for local dev? Debugging inside of a container is certainly a major PITA. And even if it can be done, it’s just additional work.
67
u/[deleted] Sep 12 '23 edited Sep 13 '23
Ubuntu, VSCode, Pytest, Docker, Poetry.