简体   繁体   English

无法连接到 digitalocean 上的 docker swarm

[英]Can't connect to docker swarm on digitalocean

I have a bit of a problem with docker swarm.我对 docker swarm 有点问题。 I create 2 instances on DigitalOcean and i'll refer to them with public ip address 100.0.0.1 and 100.0.0.2 respectively.我在 DigitalOcean 上创建了 2 个实例,我将分别使用公共 IP 地址 100.0.0.1 和 100.0.0.2 引用它们。 I ssh-ed into the first droplet as root and tried running the command docker swarm init and it returned an error that eth0 is bound to 2 ip addresses the public ip address and a private ip address.我以 root 身份 ssh 进入第一个 droplet 并尝试运行命令docker swarm init并返回一个错误,即eth0绑定到 2 个 ip 地址、公共 ip 地址和一个私有 ip 地址。
I then tried running docker swarm init --advertise-addr 10.0.0.1 as to prevent this and the swarm works.然后我尝试运行docker swarm init --advertise-addr 10.0.0.1以防止这种情况并且 swarm 工作。 But whenever I try connecting to it from anywhere either the second droplet or my local machine using the join command it prints out it returns Error response from daemon: Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the "docker info" command to see the current swarm status of your node.但是,每当我尝试使用 join 命令从第二个 droplet 或我的本地计算机的任何地方连接到它时,它都会打印出它Error response from daemon: Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the "docker info" command to see the current swarm status of your node.返回Error response from daemon: Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the "docker info" command to see the current swarm status of your node. Error response from daemon: Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the "docker info" command to see the current swarm status of your node. But it never connects to the swarm.但它永远不会连接到集群。
I tried running the same on ec2 without advertise-addr and it works perfectly the problem only arises when I am using DigitalOcean.我尝试在没有广告地址的情况下在 ec2 上运行相同的程序,它完美地工作,只有当我使用 DigitalOcean 时才会出现问题。 Any help?有什么帮助吗?
Thanks.谢谢。

For DigitalOcean docker-18-04 image:对于 DigitalOcean docker-18-04图像:

  1. Open ports, that Swarm manager need:开放端口,Swarm 管理器需要:
ufw allow 22/tcp
ufw allow 2376/tcp
ufw allow 2377/tcp
ufw allow 7946/tcp
ufw allow 7946/udp
ufw allow 4789/udp
ufw reload
ufw enable

These ports need to be open on both manager and worker nodes!这些端口需要在管理器和工作器节点上打开! 2. Restart Docker: systemctl restart docker 3. Check the name of your private network in Droplet: ifconfig -a 4. Init swarm with docker swarm init --advertise-addr eth1:2377 where eth1 is the name of Droplet private network. 2. 重新启动 Docker: systemctl restart docker 3. 在 Droplet 中检查您的私有网络的名称: ifconfig -a 4. 使用docker swarm init --advertise-addr eth1:2377初始化 swarm 其中eth1是 Droplet 私有网络的名称。

Than you will be able to join this network from worker nodes.然后你就可以从工作节点加入这个网络。

It appears that at the time of writing DigitalOcean's one-click-app for Docker is broken and fails in connecting swarm nodes for some reason.似乎在编写 DigitalOcean 的 Docker 一键式应用程序时,由于某种原因无法连接群节点。 The only workaround I found was by running a normal ubuntu (or any other OS) image and manually installing Docker.我发现的唯一解决方法是运行普通的 ubuntu(或任何其他操作系统)映像并手动安装 Docker。 That seemed to fix the problem.这似乎解决了问题。

It also worked for me.它也对我有用。 I tried with one click app that came with docker 17.12.0, and it didn't work.我尝试使用 docker 17.12.0 附带的一键式应用程序,但没有用。 I then tried a fresh install of Ubuntu with docker 18.06.1 and it worked perfectly.然后我尝试使用 docker 18.06.1 全新安装 Ubuntu,它运行良好。

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

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