本文主要是介绍理解虚拟环境virtualenv VS. Docker,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
-
Overview
virtualenv
Docker
virtualenv
is not a real isolation, it’s a poor man’s isolation using path hacks and symlinks - you are still within your own operating system.Docker
provides more isolation, but not as much as a full-on virtual machine.You could think of a container as a middle-ground between a virtualbox(heavy, expensive) and a virtualenv(light, cheap).
-
Virtualenv
virtualenv
only encapsulates Python dependencies.With a Python
vitualenv
, you can easily switch between Python versions and dependencies, but you’re stuck with your host OS. -
Docker
A
docker
container encapsulates an entire OS.With a Docker image, you can swap out the entire OS - install and run Python on Ubuntu, Debian, Alpine, even Windows Server Core.
-
汇总
简单理解,vitualenv只是针对Python软件层面的虚拟封装,可以实现不同Python版本,不同模块之间的切换,不涉及操作系统.
Docker是操作系统层面的封装,切换.
-
References
- What’s the difference between Docker and Python virtualenv?
- what is the difference between vagrant, docker, virtualenv or just a virtual machine?
- Docker Containers, Python Virtual Environments, & Virtual Machines
这篇关于理解虚拟环境virtualenv VS. Docker的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!