[英]How to use docker in both dev and production environment?
We're currently using chef for both production and development environment. 我们目前正在将厨师用于生产和开发环境。 I like the concept of docker that launches isolated containers for different service roles. 我喜欢docker的概念,它为不同的服务角色启动隔离的容器。 And I think it will work great when building a dev environment. 我认为在构建开发环境时它会很有用。 I'm a bit unclear on how we should use it in production environment (or should i use it in production environment?). 我有点不清楚如何在生产环境中使用它(或者我应该在生产环境中使用它?)。
In production, each service is already running on their dedicate server instances. 在生产中,每个服务已在其专用服务器实例上运行。 I feel it's inefficient to run them inside a container instead of directly running on the host operating system. 我认为在容器内运行它们而不是直接在主机操作系统上运行是低效的。
On the other hand, if we only use docker in dev environment, we will end up writing 2 copies of system configurations, one in docker and one in chef, which isn't ideal either. 另一方面,如果我们只在开发环境中使用docker,我们最终会编写2个系统配置副本,一个在docker中,一个在chef中,这也不理想。
Any suggestions or advices would be appreciated. 任何建议或意见将不胜感激。
In production, each service is already running on their dedicate server instances. 在生产中,每个服务已在其专用服务器实例上运行。 I feel it's inefficient to run them inside a container instead of directly running on the host operating system. 我认为在容器内运行它们而不是直接在主机操作系统上运行是低效的。
The advantage of docker in production is the ease of deployments. docker在生产中的优势在于易于部署。 To keep performances at their best, install docker on each of your production machine and have each of these docker hosts run one container only. 为了保持最佳性能,请在每台生产计算机上安装docker,并让每个docker主机只运行一个容器。 This way your apps will have access to the same amount of system resources as before. 这样,您的应用就可以像以前一样访问相同数量的系统资源。
In order to reduce the overhead that docker can induce there are a few tricks: 为了减少docker可能产生的开销,有一些技巧:
By default docker will create a new network stack for your containers, but if you use the --net=host option when running a new container then the container will use the docker host network stack instead. 默认情况下, docker将为您的容器创建一个新的网络堆栈,但如果在运行新容器时使用--net = host选项,则容器将使用docker主机网络堆栈。 This will make you container have no overhead at all regarding network performances. 这将使您的容器在网络性能方面没有任何开销。
Also note that when using --net=host
you don't need to publish ports with the -p
docker run option and do not need to expose them either. 另外请注意,当使用--net=host
,你不必与发布端口-p
泊坞窗运行选项,并不需要或者揭露他们。 Any listening port from your container processes will be accessible on the docker host ip. 可以在docker host ip上访问容器进程中的任何侦听端口。
The docker container file system is the Union file system with is slow compared to non-layered file systems. 与非分层文件系统相比,docker容器文件系统是Union文件系统。 To keep good disk performances, make sure the processes running in your container do their intensive read/write operations on a docker data volume . 要保持良好的磁盘性能,请确保容器中运行的进程在docker数据卷上执行密集的读/写操作。 Data volumes aren't part of the container layered file system and will have the performance of your docker host file system. 数据卷不是容器分层文件系统的一部分,并且具有docker主机文件系统的性能。
Docker is actually pretty efficient - the overhead isn't that big, because it's not like a virtualization layer, it's just a container with its own namespace and FS. Docker实际上非常高效 - 开销并不大,因为它不像虚拟化层,它只是一个拥有自己的命名空间和FS的容器。 Deploying the same setup to production has several advantages: 将相同的设置部署到生产中有几个优点:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.