部署 swarm 集群后是否需要 'local' 虚拟机?

Is the 'local' vm required once the swarm cluster has been deployed?

根据 Install and Create a Docker Swarm 上的官方文档,第一步是创建一个名为 local 的虚拟机,它需要用 swarm create 获取令牌。

创建管理器和所有节点并将其添加到 swarm 集群后,我是否需要保留 运行 local 虚拟机?

Note: this tutorial is for the first version of Swarm (called Swarm legacy). There is a new version called Swarm mode available since Docker 1.12. Putting it out there because there seems to be a lot of confusion between the two.

不,您不必保留 local VM,这只是为了使用 Docker Hub 发现服务获取唯一的集群令牌.

现在仅仅生成一个令牌有点矫枉过正。您可以通过以下方式绕过此步骤:

  • 运行 如果您有 Docker for Mac 或更一般的 Docker 运行:[=18= 的本地实例,则直接使用 swarm 容器]

    docker run --rm swarm create
    
  • 直接查询服务发现URL生成token:

    curl -X POST "https://discovery.hub.docker.com/v1/clusters"