Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I haven't had to write python in awhile but are there reasons to use virtualenv etc. instead of a docker container?


Yes: Docker adds an enormous amount of overhead. Instead of your Python code you now have to manage a second operating system for the host (including things like not being able to debug or edit directly, having to debug networking, etc.) and whatever OS + deployment is happening in the actual container.

For deployment, Docker solves a lot of problems but there's a significant cost for local development.


I actually prefer to use Docker, especially on projects with multiple people. The amount of times people shipped code without adding dependencies, or on-boarding new people who wouldn't read the docs to install system dependencies was astounding. Now it's as easy as install Docker, and running `docker-compose up` and since our CI and servers use the same images it's virtually guaranteed to work. I've also noticed a huge productivity leap being able to use sql serves as containers rather than installing them on the system! so much easier to manage!


> install system dependencies

This is the important point of Docker. If your app has dependencies that are outside of the Python ecosystem (especially the pita ones to install) Docker seems like an excellent solution. I have an app that requires Oracle drivers and some other binaries with custom compile options (not available through apt) on Linux and I really wish I had built it in Docker.


Less of a pain in the ass for rapid iteration, zero overhead, fewer dependencies = less complexity.

Virtualenv is literally a set of shims in your $PATH and some tooling to manage those sets. Pyenv is the same thing, but extends the concept out to your actual Python interpreter and lets you rapidly switch between them.


I wish you weren't getting downvoted for this. docker-compose is honestly no more complicated of a thing than virtualenv to use.

That said, main reason to do it is that python is a language of idioms and this is one. It's easier to take the trail than break your own.


Agreed. I don’t see how Docker is slower once the compose environment is setup (especially if you’re running Docker in Linux), and proper volume mounts are made to the source files. In fact, I would say developing with Docker will help with deploying to production, because you’ll be able to see how the app will work in production.

I can see Docker being slower if virtualized, but on Linux, it’s just a fancier BSD jail, no?


I find virtualenv much easier to manage and use than docker. Unless you're changing dependencies and versions multiple times over a day, it's not a pain.


Docker is SLOW to build the image. Virtualenv is great for development.


But you do not have to build the image while developing (in Python). Just map your project into the image using `-v`.


Why are you building the image so much? Just mount a pre-built image


Yes you don't need a whole linux distro for what's simply a set of libraries and a binary file

Docker container is just the lazy solution




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: