Docker Swarm makes you more effective

Source: Internet
Author: User
Tags docker swarm docker machine

2016 Dockercon (God ...) How I wish I had been there. One of the most significant changes shown was the Swarm model of the 1.12 version engine. What does it mean? It means: If you are running Docker 1.12, you can create a Swarm cluster natively. Create a swarm cluster

With such a simple command:

$ Docker Swarm Init

Is enough to create a Swarm (although it is a Swarm with simple management nodes, it is already the simplest collection of Swarm clusters).

$ docker Node LsID                           HOSTNAME  Membership  STATUS  availability  MANAGER STATUS7SYTB3ZK0YSWDFKY6MBH7NZK2 *  Moby      Accepted    ready   Active        Leader

Let's take a look at the Multi-node! With only one node Swarm, the use is limited, so let's create a Swarm with two management nodes (manager nodes) and two working nodes (worker nodes). First, let's create a 4 Docker host. Docker Machine is the ideal tool to accomplish this task, so we use it.

$ docker-machine lsname ACTIVE DRIVER State URL SWARM Docker Errorsmanager1-virtualbox Running tcp://192.168.99.100:2376 V1.12.0-rc3manager2-virtualbox Running tcp://192.168.99.101:2376 v1.12.0-rc3worker1-virtualbox Running tcp:// 192.168.99.102:2376 V1.12.0-rc3worker2-virtualbox Running tcp://192.168.99.103:2376 v1.12.0-rc3

If you have no other machine-created host on hand, your display information will need to be closer to the example given below when displaying the cluster nodes.

$ docker-machine lsname              ACTIVE   DRIVER         State     URL                         SWARM   Docker        ERRORSmanager1          -        VirtualBox     Running   tcp://192.168.99.100:2376           v1.12.0-rc3manager2          -        virtualbox     Running   tcp:/ /192.168.99.101:2376           v1.12.0-rc3worker1           -        virtualbox     Running   tcp:// 192.168.99.102:2376           v1.12.0-rc3worker2           -        virtualbox     Running   tcp://192.168.99.103:2376           V1.12.0-RC3
Initialize Swarm

The simplest command to create a Swarm with the version 1.12 engine (hint: "Docker Swarm Init") is described above, but here we will also invoke several additional options to allow the cluster hosts to communicate with each other and join the cluster without permission.

$ manager1_ip=$ (docker-machine IP manager1) $ docker-machine ssh manager1 Docker swarm init--auto-accept manager--auto-ac CEPT worker--listen-addr $MANAGER 1_ip:2377

Note:–listen-addr is an address that is accessed by different nodes within the Swarm

Add a second management node

You also need to add some options in the Docker Swarm command:

* Join: Indicates that a new node will be added into the Swarm

*?–manager: Indicates the nature of the node (manager vs worker)

*?–LISTEN-ADDR: Allows a newly added node to access other nodes within the Swarm

* The last parameter is the address of the first management node (that is, the node to which this command will be sent)

Note: because the –auto-accept manager option is provided during Swarm initialization, the second management node is automatically accepted. Without this option, the second management node needs to be manually accepted by the first management node.

$ manager2_ip=$ (docker-machine IP manager2) docker-machine ssh manager2 docker swarm join--manager--listen-addr $MANAGER 2_ip:2377 $MANAGER 1_ip:2377
Add a work node

The way to add work nodes to a cluster is almost the same as adding a management node:

$ worker1_ip=$ (docker-machine IP worker1) $ docker-machine ssh worker1 Docker swarm join--listen-addr $WORKER 1_ip:2377 $MA nager1_ip:2377$ worker2_ip=$ (docker-machine IP worker2) $ docker-machine ssh worker2 Docker swarm join--listen-addr $WORK er2_ip:2377 $MANAGER 1_ip:2377

Note: since the –auto-accept worker? option is provided during Swarm initialization, the work node is automatically accepted. Without this option, the work node needs to be manually accepted by the management node.

What does our Swarm look like? Let's take a look.

$ docker-machine SSH manager1 docker node LsID                           HOSTNAME  Membership  STATUS  availability  MANAGER STATUS109A5UFY8E3EY17UNQA16WBJ7    manager2  Accepted    ready   Active        REACHABLE4CHBN8UPHM1TIDR93S64ZKNBQ *  manager1  Accepted    ready   Active        leader8nw7g1q0ehwq1jrvid1axtg5n    worker2   Accepted    ready   active8rrdjg4uf9jcj0ma2uy8rkw5v    Worker1   Accepted    Ready   Active

Each node now belongs to Swarm and is in standby mode. Management Node 1 is the leader, everything is in its place, well-organized, what makes it so special?
This Swarm is guaranteed by the Secure Transport Layer Protocol (TLS) and can be automatically certified for upgrade outside of the device.

Similarly, it no longer requires key-value storage such as Consul, Zookeeper, and everything is under control.

Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/

Docker Swarm makes you more effective

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.