使用 Docker Swarm 即时添加节点

Adding nodes on the fly with Docker Swarm

我运行正在使用静态 IP 列表构建一个群,我想添加一个节点。

显而易见的解决方案是退出使用 swarm manage -H 2375:2375 <node_ip1:2375> 和 运行 swarm manage -H 2375:2375 <node_ip1:2375>,<node_ip2:2375>.

创建的集群

是否有另一种解决方案来执行类似 swarm add <node_ip2:2375> 添加第二个节点到我的 运行ning 群?

不,如果不手动重启 swarm 并添加新主机,就无法使用 IP 列表添加动态节点。但是,如果您将 swarm 与服务发现结合使用,则可以做到。

您可以找到 here the needed reference to implement docker-swarm with service discovery and how join nodes dynamically. Note that you can use any of these Discovery backends.