Docker Swarm cluster creation

Source: Internet
Author: User
Tags docker swarm

First, the Environment preparation

1. Prepare 3 virtual machines with IP and hostname settings as follows

192.168.71.137

Manager1

192.168.71.141

Worker1

192.168.71.140

Worker2


2. System and Software versions

System version

[Email protected] ~]# cat/etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

Kernel version

[Email protected] ~]# uname-r

3.10.0-327.36.1.el7.x86_64

Docker version

[Email protected] ~]# docker-v

Docker version 1.12.2, build bb80604


3. Firewall to open the relevant port

Release the port:

TCP 2,377 Cluster Management communication required

Required for communication between TCP and UDP 7946 nodes

TCP and UDP 4789 Overlay network required

The command is as follows:

Firewall-cmd--add-port=2377/tcp

Firewall-cmd--add-port=2377/tcp--permanent

Firewall-cmd--add-port=7946/tcp--add-port 7946/udp

Firewall-cmd--add-port=7946/tcp--add-port 7946/udp--permanent

Firewall-cmd--add-port=4789/tcp--add-port 4789/udp

Firewall-cmd--add-port=4789/tcp--add-port 4789/udp--permanent


Second, swarm cluster creation

1. Create a swarm cluster

Initialize command as follows, I use 192.168.71.137 as manager here

Docker swarm Init--advertise-addr <MANAGER-IP>

[email protected] ~]# docker swarm init--advertise-addr 192.168.71.137

Swarm initialized:current Node (8d1kzvnv99q2gy82ulrklezom) is now a manager.


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


Docker swarm join \

--token swmtkn-1-12k7eupx7wbuhdhyb1qo2vu8q49x8k4uq0d0t62ksb8irlylex-6fz55egsirm1l5076pin7ksc6 \

192.168.71.137:2377


To add a manager to this swarm, run ' Docker swarm Join-token Manager ' and follow the instructions.


According to the above hints, it is known that the node joins the cluster to perform the above command returned.


View Docker info, show Docker working in swarm mode

[[email protected] ~]# Docker info

...

Swarm:active

...

View Management node started up one node

[email protected] ~]# docker node ls

ID HOSTNAME status Availability MANAGER status

8d1kzvnv99q2gy82ulrklezom * Manager1 Ready Active Leader


Execute a cluster-joined command on WORK1, Worker2

[[email protected] ~]# Docker swarm join \

>--token swmtkn-1-12k7eupx7wbuhdhyb1qo2vu8q49x8k4uq0d0t62ksb8irlylex-6fz55egsirm1l5076pin7ksc6 \

> 192.168.71.137:2377

This node joined a swarm as a worker.


[[email protected] ~]# Docker swarm join \

>--token swmtkn-1-12k7eupx7wbuhdhyb1qo2vu8q49x8k4uq0d0t62ksb8irlylex-6fz55egsirm1l5076pin7ksc6 \

> 192.168.71.137:2377

This node joined a swarm as a worker.


If the above command does not remember, you can use the following command on the Manager1 node to view

[email protected] ~]# Docker swarm Join-token worker

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


Docker swarm join \

--token swmtkn-1-12k7eupx7wbuhdhyb1qo2vu8q49x8k4uq0d0t62ksb8irlylex-6fz55egsirm1l5076pin7ksc6 \

192.168.71.137:2377

View node list information again on the Manager1 node

[email protected] ~]# docker node ls

ID HOSTNAME status Availability MANAGER status

8d1kzvnv99q2gy82ulrklezom * Manager1 Ready Active Leader

8iwemhb8ux2fedbdn12c9igii Worker2 Ready Active

Bdmj4stzpnwmkovonnxj6u4q9 Worker1 Ready Active

Description The cluster has been created to complete.

This article is from the "rain or Keep Falling" blog, please be sure to keep this source http://8869176.blog.51cto.com/8859176/1866884

Docker Swarm cluster creation

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.