如何在多个远程计算机上设置Docker群集的多主机联网 [英] How to setup multi-host networking with docker swarm on multiple remote machines

查看:486
本文介绍了如何在多个远程计算机上设置Docker群集的多主机联网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在提出这个问题之前,我已经阅读了安静的文章和stackoverflow问题,但是我无法得到我的设置的正确答案(也许已经回答了)。这是我一直努力工作的架构。


  1. 我有三台物理机器,我想设置Docker群与多主机联网,以便我可以运行docker-compose。

例如:


$ b机器1(Docker Swarm Manager and Contains Consoul)(192.168.5.11)
  • 机器2(Docker Swarm Node)(192.168.5.12)

  • 机器3(Docker Swarm Node)(192.168.5.13)

  • 我需要运行停泊码头 - 从任何其他单独的机器组成。



    我尝试过 Docker文章,但在该文章中,它都是使用docker-machine和virtual box在同一物理机上进行设置的。如何在三台远程机器上实现以上功能。任何帮助赞赏。

    解决方案

    最新版本的Docker具有群组模式,所以您不需要领事。



    设置在您的盒子上,确保它们都具有1.12或更高版本的 docker版本,然后您只需要初始化群组并加入。



    在机器1上运行:

      docker swarm init --advertise-addr 192.168.5.11 

    该输出将告诉您在机器2和3上运行的命令将其加入到群集中。您将拥有一个独特的群体令牌,命令如下:

      docker swarm join \ 
    - -token SWMTKN-1-49nj1 ... \
    192.168.5.11:2377

    现在你有一个3节点群。回到机器1,您可以创建一个多主机覆盖网络:

      docker network create -d overlay my-app 

    然后,您可以通过部署服务。如果您想使用组合模式,您需要使用分布式应用程序包目前仅在Docker的实验版本中。


    Before asking this question I have read quiet of articles and stackoverflow questions but I couldn't get the right answer for my setup(perhaps it is already answered). Here is the architecture I have been struggling to get it to work.

    1. I have three physical machines and I would like to setup the Docker swarm with multi-host networking so that I can run docker-compose.

    For example:

    1. Machine 1(Docker Swarm Manager and Contains Consoul)(192.168.5.11)
    2. Machine 2(Docker Swarm Node)(192.168.5.12)
    3. Machine 3 (Docker Swarm Node)(192.168.5.13)

    And I need to run docker-compose from any other separate machine.

    I have tried Docker article but in that article it is all setup under the same physical machine using docker-machine and virtual box. How can I achieve above in three remote machines. Any help appreciated.

    解决方案

    The latest version of Docker has Swarm Mode built in, so you don't need Consul.

    To set up on your boxes, make sure they all have docker version of 1.12 or higher and then you just need to initialise the swarm and join it.

    On Machine 1 run:

    docker swarm init --advertise-addr 192.168.5.11
    

    The output from that will tell you the command to run on Machine 2 and 3 to join them to the swarm. You'll have a unique swarm token, and the command is something like:

    docker swarm join \
    --token SWMTKN-1-49nj1... \
    192.168.5.11:2377
    

    Now you have a 3-node swarm. Back on Machine 1 you can create a multi-host overlay network:

    docker network create -d overlay my-app
    

    And then you run workloads in the network by deploying services. If you want to use Compose with Swarm Mode, you need to use distributed application bundles - which are currently only in the experimental build of Docker.

    这篇关于如何在多个远程计算机上设置Docker群集的多主机联网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆