github.com/dpiddy/docker@v1.12.2-rc1/docs/swarm/swarm-tutorial/create-swarm.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Create a swarm"
     4  description = "Initialize the swarm"
     5  keywords = ["tutorial, cluster management, swarm mode"]
     6  [menu.main]
     7  identifier="initialize-swarm"
     8  parent="swarm-tutorial"
     9  weight=12
    10  +++
    11  <![end-metadata]-->
    12  
    13  # Create a swarm
    14  
    15  After you complete the [tutorial setup](index.md) steps, you're ready
    16  to create a swarm. Make sure the Docker Engine daemon is started on the host
    17  machines.
    18  
    19  1. Open a terminal and ssh into the machine where you want to run your manager
    20  node. For example, the tutorial uses a machine named `manager1`.
    21  
    22  2. Run the following command to create a new swarm:
    23  
    24      ```bash
    25      docker swarm init --advertise-addr <MANAGER-IP>
    26      ```
    27  
    28      >**Note:** If you are using Docker for Mac or Docker for Windows to test
    29  single-node swarm, simply run `docker swarm init` with no arguments. There is no
    30  need to specify ` --advertise-addr` in this case. To learn more, see the topic
    31  on how to [Use Docker for Mac or Docker for
    32  Windows](index.md#use-docker-for-mac-or-docker-for-windows) with Swarm.
    33  
    34      In the tutorial, the following command creates a swarm on the `manager1`
    35      machine:
    36  
    37      ```bash
    38      $ docker swarm init --advertise-addr 192.168.99.100
    39      Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager.
    40  
    41      To add a worker to this swarm, run the following command:
    42  
    43          docker swarm join \
    44          --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
    45          192.168.99.100:2377
    46  
    47      To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
    48      ```
    49  
    50      The `--advertise-addr` flag configures the manager node to publish its
    51      address as `192.168.99.100`. The other nodes in the swarm must be able
    52      to access the manager at the IP address.
    53  
    54      The output includes the commands to join new nodes to the swarm. Nodes will
    55      join as managers or workers depending on the value for the `--token`
    56      flag.
    57  
    58  2. Run `docker info` to view the current state of the swarm:
    59  
    60      ```bash
    61      $ docker info
    62  
    63      Containers: 2
    64      Running: 0
    65      Paused: 0
    66      Stopped: 2
    67        ...snip...
    68      Swarm: active
    69        NodeID: dxn1zf6l61qsb1josjja83ngz
    70        Is Manager: true
    71        Managers: 1
    72        Nodes: 1
    73        ...snip...
    74      ```
    75  
    76  3. Run the `docker node ls` command to view information about nodes:
    77  
    78      ```bash
    79      $ docker node ls
    80  
    81      ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
    82      dxn1zf6l61qsb1josjja83ngz *  manager1  Ready   Active        Leader
    83  
    84      ```
    85  
    86      The `*` next to the node id indicates that you're currently connected on
    87      this node.
    88  
    89      Docker Engine swarm mode automatically names the node for the machine host
    90      name. The tutorial covers other columns in later steps.
    91  
    92  ## What's next?
    93  
    94  In the next section of the tutorial, we'll [add two more nodes](add-nodes.md) to
    95  the cluster.