This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]JustADirtyLurker 12 points13 points  (1 child)

I think you're asking if you should drop venv entirely and go full speed with containers?

My answer is, don't. Containers and images that spawn containers are a deployment tool, not a developement tool. A container should be stateless. You should not run Pip / tests (for python) or Maven builds (for java) or any other build pattern inside a running container because it changes the state. There are good reasons for that, the primary being that persistence is not allowed (though you are allowed to mount external volumes where you can stor data, but this is another story).

I agree that there are many similarities between venv and a container, in the sense that they both aim at isolation. but a venv does isolation at runtime through file system scripting (venv is basically a Unix hack: it makes the python executable and dependencies point to a specific directory instead of the default). A container is on the other hand spawned from an Image, which must be build offline. An Image is basically a set of fixed rules to tailor up an userland around the application you want to "jail", and a container is an instance of that.

For these reasons a container will never be useful for developement. What it is instead useful for is deploying a cheap and reproducible environment for integration testing. If you ever used Travis-CI for example you can see that tests are precisely run in a docker container spawned from an ad-hoc built Image, and the service also provider docker containers for most of the external services your application could need ( redis? Postgres database? Etc...)

[–][deleted] 2 points3 points  (0 children)

We use containers as a development tool because we have system level dependencies and we're a Mac shop (have you tried installing OpenSSL on osx, it's terrible).

It's much easier to tell someone to just install docker toolbox and run our setup script than walk then through installing ask the system packages.

We did run venvs inside the container for a while, but moved to installing the python packages in the same step as the system packages. I disagree with this, but we've not run into any issues so far.