简体   繁体   English

使用Docker for Mac创建一个群集群集

[英]Creating a swarm cluster with Docker for Mac

I've been trying to follow this tutorial: https://docs.docker.com/engine/swarm/swarm-tutorial/ 我一直在尝试遵循这个教程: https//docs.docker.com/engine/swarm/swarm-tutorial/

Instead of running it on some real linux hosts or local VMs I want to network a couple of MacBooks running Docker desktop for Mac . 我没有在一些真正的Linux主机或本地虚拟机上运行它,而是想为几台运行适用于Mac的Docker桌面的MacBook进行网络连接。

Following the tutorial I've installed Docker desktop for Mac on two machines. 在本教程之后,我在两台机器上安装了适用于Mac的Docker桌面。 In a terminal on the first machine docker swarm create works and creates a ca hash and id. 在第一台机器上的终端上, docker swarm create工作并创建一个ca hash和id。

Carrying on to the second machine I execute the join command by pasting it from one to the other. 继续第二台机器,我通过将其从一个粘贴到另一个来执行连接命令。

The second machine cannot connect. 第二台机器无法连接。 This is expected since the IP address show in the output is clearly the IP address inside the virtual machine and not an address on my machine. 这是预期的,因为输出中显示的IP地址显然是虚拟机内的IP地址,而不是我机器上的地址。 I tried diverting from the tutorial by specifying the address of the local network adaptor but it says it cannot bind to that address. 我尝试通过指定本地网络适配器的地址从教程转移,但它说它无法绑定到该地址。 I know all the ports are open and the machine can connect to each other. 我知道所有端口都是打开的,机器可以相互连接。

So it seems to me I'm fundamentally misunderstanding the aim of the tutorial or how to setup the two Macs so they can communicate. 所以在我看来,我从根本上误解了教程的目的或如何设置两台Mac,以便他们可以进行通信。 By googling for solutions it seems there are several possibilities for what I need to do: 通过Google搜索解决方案,似乎我需要做几件事:

Run a distributed kv store to help the swarm network coordinate (but isn't this the point of the new orchestration?) Set up a port tunnel on each machine from the network adaptor to the alpine linux docker daemon Give up and just test my cluster locally 运行分布式kv存储来帮助群集网络协调(但这不是新业务流程的重点?)在每台机器上设置从网络适配器到alpine linux docker守护程序的端口隧道放弃并只测试我的集群本地

Update: after some more research it seems I should create an overlay network using this guide. 更新:经过一些研究后,似乎我应该使用本指南创建一个覆盖网络。 But this guide uses docker-machine. 但本指南使用的是docker-machine。 As far as I understand I should/can not use docker-machine along with Docker desktop for Mac, or is that incorrect? 据我所知,我应该/不能使用docker-machine和Docker桌面用于Mac,或者这是不正确的?

https://docs.docker.com/engine/userguide/networking/get-started-overlay/ https://docs.docker.com/engine/userguide/networking/get-started-overlay/

You have to set up a port tunnel to promote the docker daemon port inside the VM to the hosts network interface. 您必须设置端口隧道以将VM内的docker守护程序端口提升为主机网络接口。 To check if you can reach the daemon of another machine use https://otherMachineIp:DaemonPort/v1/_ping . 要检查是否可以访问另一台计算机的守护程序,请使用https:// otherMachineIp:DaemonPort / v1 / _ping If this succedes you can reach the other daemon to set up a swarm. 如果成功,您可以到达另一个守护进程来设置群。

BTW as long as you are on the same docker version, using Docker for Mac and docker-machine together should not cause problems. BTW,只要你使用相同的docker版本,使用Docker for Mac和docker-machine一起不应该导致问题。

But this guide uses docker-machine. 但本指南使用的是docker-machine。

That should not be an issue: each time you see in the tutorial 这应该不是问题:每次你在教程中看到

Point your environment to the Swarm master. 将您的环境指向Swarm主站。

$ eval $(docker-machine env --swarm mhs-demo0)

It simply means you are supposed to execute the next docker command on the swarm master (one of your mac) 它只是意味着你应该在swarm master(你的一个mac)上执行下一个docker命令

Switch to each Swarm agent in turn and list the networks. 依次切换到每个Swarm代理并列出网络。

$ eval $(docker-machine env mhs-demo0)

Similarly, you switch to your other mac to execute other docker commands. 同样,您切换到其他mac来执行其他docker命令。

As of Docker 1.12 this is not possible. 从Docker 1.12开始,这是不可能的。 It may be worked on in a later version. 它可以在更高版本中使用。

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

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