简体   繁体   English

docker-swarm vs.docker-compose 在生产中的单个主机上

[英]docker-swarm vs.docker-compose on single host in production

Is there a reason to use docker-swarm instead of docker-compose for deploying a single host in production?是否有理由使用 docker docker-swarm而不是docker-compose在生产中部署单个主机?

I'm currently rewriting an existing application.我目前正在重写现有的应用程序。 My predecessors set up the application using docker-swarm.我的前辈使用 docker-swarm 设置应用程序。 But I do not understand why: the application will only consist of a single host running a couple of services.但我不明白为什么:该应用程序将只包含一个运行几个服务的主机。 These services will only supply some local information on the customer network via a REST-Api to a kubernetes cluster (so no real load or reason to add additional hosts).这些服务将仅通过 REST-Api 向 kubernetes 集群提供客户网络上的一些本地信息(因此没有实际负载或添加额外主机的理由)。

I looked through the Docker website and could not find a reason to use docker-swarm to deploy a single host, apart from testing a deployment on a single host dev environment.我浏览了 Docker 网站,除了在单主机开发环境上测试部署外,找不到使用 docker docker-swarm部署单主机的理由。

Are there benefits of using docker-swarm compared to docker-compose regarding deployment, networking, etc...?docker-compose在部署、网络等方面相比,使用 docker docker-swarm是否有好处?

Docker Swarm and Docker Compose are fundamentally different animals. Docker Swarm 和 Docker Compose 是根本不同的动物。 Compose is a build tool that lets you define and configure a group of related containers, whereas swarm is an orchestration tool that manages multiple docker engines in a way that lets you treat them (somewhat) as a single unit. Compose 是一种构建工具,可让您定义和配置一组相关容器,而 swarm 是一种编排工具,可管理多个 docker 引擎,让您(在某种程度上)将它们视为一个单元。 Swarm exposes an API that is mostly compatible with the Docker Remote API, which allows existing applications to use Swarm to scale horizontally without having to completely overhaul the existing interface to the container engine. Swarm 公开了一个 API,它与 Docker 远程 API 大部分兼容,它允许现有应用程序使用 Swarm 水平扩展,而无需完全检修容器引擎的现有接口。

That said, much of the functionality in Docker Compose that overlaps with Docker Swarm has been added incrementally.也就是说,Docker Compose 中与 Docker Swarm 重叠的大部分功能已逐步添加。 Compose has grown over time, and the distinction between the two has narrowed a bit. Compose 随着时间的推移而增长,两者之间的区别已经缩小了一点。 Swarm was eventually integrated into the Docker engine, and Docker Stack was introduced, allowing compose.yml files to be read directly by Docker, without using Compose. Swarm 最终被集成到 Docker 引擎中,并引入了 Docker Stack,允许compose.yml直接读取 compose.yml 文件,而无需使用 Compose。

So the real question might be: what is the difference between docker compose and docker stack?所以真正的问题可能是: docker compose 和 docker 堆栈之间有什么区别? Not a whole lot.不是很多。 Compose is actually a separate project, written in Python that uses the Docker API under the hood. Compose 实际上是一个单独的项目,用 Python 编写,底层使用 Docker API。 Stack does much of the same things as Compose, but is integrated into Docker. Stack 与 Compose 做很多相同的事情,但集成到 Docker 中。 Stack also wants pre-built images, while compose will handle those image builds for you, which makes compose very handy for development. Stack 还需要预先构建的图像,而 compose 会为您处理这些图像构建,这使得 compose 对于开发非常方便。

What you are dealing with might be a product of a time when these 2 tools were a lot more distinct.您正在处理的可能是这两种工具更加不同的时代的产物。 Docker Swarm is part of Docker, and it allows for easy scaling if needed (even if you don't need it now, it might be good down the road). Docker Swarm 是 Docker 的一部分,如果需要,它可以轻松扩展(即使您现在不需要它,它也可能会很好)。 On the other hand, Compose (in my opinion anyway) is much more useful for development situations where you are making frequent tweaks to your images, and rebuilding.另一方面,Compose(无论如何在我看来)对于您经常调整图像和重建的开发情况更有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM