Swarm Mode Deployment

Swarm Introduction

Swarm is a native cluster tool for docker. Swarm uses the standard Docker API which means the container can start with the docker run command. Swarm will choose the appropriate host to run the container, which means that other tools using the Docker API, such as the compose and bespoke scripts, can also use swarm, so that it can use cluster instead of running on a single host.

The basic framework of swarm is simple: each host runs a swarm agent, one host runs Swarm Manager(in the test cluster, the host can also run the agent), which is responsible for the arrangement and scheduling of the container on the host. Swarm can run with high availability mode(etcd, consul or any of the Zookeeper can be used to transfer faults to back manager processing). When a new host is added to the cluster, there are several different ways to discover the new host, which is discovery in swarm. The default is token, which is the list of host addresses that are stored on the Docker Hub.

Deploy Swarm Mode

You need to bind docker to the specified TCP port before deploying Swarm Mode. Please refer to Use iManager > Compose Application Management > Confugure Resource Pool.

This document takes ubuntu 14.04 operation system as an example, and deploys Swarm Mode on machines which ips are and, where is the main node and is the worker node.

  1. Execute the following command on to set up to manage.

    docker swarm init --listen-addr
    docker swarm join-token --rotate worker

    You can see the following information:

    Successfully rotated worker join token.

    To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-0velpgoh1rgws30497sm55az01darmlji77hembfrxtkafirvq-0zybv26gbvstngl4cyk5py5u3
  2. Execute the previous step output on to join to swarm mode as a worker. Such as:

    docker swarm join --token SWMTKN-1-0velpgoh1rgws30497sm55az01darmlji77hembfrxtkafirvq-0zybv26gbvstngl4cyk5py5u3

    If you see “This node joined a swarm as a worker” meaning success. If you fail, please refer to Appendix > FAQ Question 13.


  3. Execute the following command on to view the node lists of Swarm Mode.

    docker node ls

    You can see the following information:


    If you want to delete a worker node, you can execute the following command on, which you need to replace the Node ID with the ID of the specific node. The node ID can be viewed through the command of step 3.

    e.g. :