docker - Docker在单个主机上扩展容器

标签 docker docker-swarm

我可以理解在docker swarm中扩展容器(作为服务)的优点,这些容器分布在多个物理主机服务器上,但是在单个物理主机上扩展容器(不使用swarm)也有优势,如果可以的话这些是什么?

docker-compose scale apache=4

最佳答案

您可以在Martin Villalba的“Docker Compose: Scaling Multi-Container Applications”中看到单主机服务扩展的示例
在这种情况下,您需要注意的地方是:

ensure that the service we want to scale does not specify the external/host port. If we specify that port, the service cannot be scaled since all the instances would try to use the same host port.


在那篇文章中,.Net Web应用程序可以在多个容器中扩展,并可以通过负载平衡器进行访问。
即使在单个物理主机上,也可以更好地在不同容器之间分配和分配物理机的资源。如果这些容器之一发生故障,另一个仍可以提供预期的服务。

OP paj指向他的文章“Docker Mono Host Service Scaling and Dynamic Load Balancing with NGINX”来说明这一点。

are there any benefits from scaling a service in mulitple containers on a single host?

Well, yes, because you can still load balance the traffic to your application and achieve a basic level of container resilience.


他使用NGiNX http_dyups_module允许动态更新NGINX上游主机配置。

关于docker - Docker在单个主机上扩展容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44477049/

相关文章:

docker - docker特权模式和kubernetes特权容器的区别

java - Jenkins : Cannot run program "docker": error=2, 没有那个文件或目录

docker - 为在 Kubernetes 中运行的容器设置主机名

docker - 如何设置具有覆盖网络模式的 Docker Swarm 集群

docker - Docker在运行群集集群的机器上构建速度极慢

macos - CAN 所需的原始套接字无法在 MacOS 下工作 - 套接字 : Address family not supported by protocol

apache - 单台服务器上有多个Docker容器

javascript - 如何在多个 Docker 副本中仅运行一次计划代码?

docker - 是否可以将ELK作为Docker服务运行?

amazon-web-services - 有没有办法在 Docker 群中运行每个服务以使用不同的 IAM 角色运行