Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...