Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

python - Does virtualenv serve a purpose (in production) when using docker?

For development we use virtualenv to have an isolated development when it comes to dependencies. From this question it seems deploying Python applications in a is recommended.

Now we're starting to use for deployment. This provides a more isolated environment so I'm questioning the use of virtualenv inside a docker container. In the case of a single application I do not think virtualenv has a purpose as docker already provides isolation. In the case where multiple applications are deployed on a single docker container, I do think virtualenv has a purpose as the applications can have conflicting dependencies.

Should virtualenv be used when a single application is deployed in a docker container?

Should docker contain multiple applications or only one application per container?

If so, should virtualenv be used when deploying a container with multiple applications?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Virtualenv was created long before docker. Today, I lean towards docker instead of virtualenv for these reasons:

  • Virtualenv still means people consuming your product need to download eggs. With docker, they get something which is "known to work". No strings attached.
  • Docker can do much more than virtualenv (like create a clean environment when you have products that need different Python versions).

The main drawback for Docker was the poor Windows support. That changed with the version for Windows 10.

As for "how many apps per container", the usual policy is 1.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...