docker1.12.0 Swarm cluster

Source: Internet
Author: User
Tags docker swarm

Test environment:

M Anager :

192.168.209.129 Docker_node1

Node:

192.168.209.130 Docker_node2

Systems and Software:CentOS 7.2 Docker 1.12.0

1. Initializing the swarm cluster

[[email protected] ~]# Docker swarm Init

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/85/DF/wKioL1etNSij6LhVAAAwcqyht9Q282.png "title=" Picture 1.png "alt=" wkiol1etmrgibaf4aaawcqyht9q483.png-wh_50 "/>

You can also use parameters:

--listen-addr Specify Listener ( format : <ip|interface>[:p ort]) ( default : 0.0.0.0:2377)

--ADVERTISE-ADDR Specify notification network card ( format : <ip|interface>[:p ort])

The post-execution return information includes two commands , namely joining node and joining the manager

2. Add docker_node2 to the cluster, according to the prompt command

[email protected] ~]# docker swarm join--token \

Swmtkn-1-1toyv27479tfrruwqj14l7dc6gsju4w4u8957wikn59kjlqqdu-dj71uypb64ckw0wylvq7svmzw\

192.168.209.129:2377

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/85/DF/wKiom1etNU2CqKiZAAAZ8iUiNp0425.png "title=" Picture 6.png "alt=" Wkiom1etnu2cqkizaaaz8iuinp0425.png "/>

Receive this node joined a swarm as a worker after execution is complete.

[email protected] ~]# Docker swarm--help

Commands:init Initialize a swarm join join a swarm as a node and/or manager Join-token Manage join Toke NS Update update The Swarm leave leave a swarm

3. View cluster status information

Manager:

[[email protected] ~]# Docker info

Swarm:active Nodeid:awsh1ay3dvghh9kuuoipbnanj is manager:true clusterid:eelrml6monrirrlp1qzou45nb managers:1 nodes:2 Orchestration:task history Retention limit:5 raft:snapshot interval:10000 Heartbeat tick:1 election tick:3 Disp Atcher:heartbeat period:5 seconds CA configuration:expiry duration:3 months Node address:192.168.209.129

Node:

[[email protected] ~]# Docker info

Swarm:active Nodeid:6tm7yidwzw69c8byp5rtoeqel is Manager:false Node address:192.168.209.130

View node information

[email protected] ~]# docker node ls

ID HOSTNAME STATUS availability MANAGER Status6tm7yidwzw69c8byp5rtoeqel Docker-node2 Ready Active Awsh1ay3dvghh9kuuoipbnanj * Docker-node1 ready Active Leader

can also be used Inspect View more information

[email protected] ~]# Docker node inspect 6tm7yidwzw69c8byp5rtoeqel

[email protected] ~]# Docker node--help

Commands:demote demote a node from manager in the Swarm inspect Display detailed information on one or more No Des LS List nodes in the swarm promote promote a node to a manager in the Swarm RM Remove a node From the Swarm PS List tasks running on a node update update a node


Docker Service

1. Create nginx service

[[email protected] ~]# Docker service Create--name Web--publish 80:80--replicas 2 nginx

6x1ymmvsugcxtib6sjyjat4yd

Note:

Docker Service create creates the service command--name name--publish Specifies the number of service ports--replicas running container the Nginx image name

2. View the created service

[[email protected] ~]# Docker service ls

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/85/DE/wKioL1etND2ywwZeAAAMr1lX3ZU748.png "title=" Picture 2.png "alt=" Wkiol1etnd2ywwzeaaamr1lx3zu748.png "/>

View the running state, where you see a container running in docker-node1,docker-node2 , respectively

[[email protected] ~]# Docker service PS Web

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/85/DF/wKiom1etNFTwDQfEAAAWfHaXWE4176.png "title=" Picture 3.png "alt=" Wkiom1etnftwdqfeaaawfhaxwe4176.png "/>

3. Online expansion, the number of Web containers changed to 5

[email protected] ~]# Docker Service scale web=5

Web scaled to 5

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/85/DE/wKioL1etNJGTB6VAAAA5brWi2Uk917.png "title=" Picture 4.png "alt=" Wkiol1etnjgtb6vaaaa5brwi2uk917.png "/>

4. Online reduction

[email protected] ~]# Docker Service scale web=3

Web scaled to 3

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/85/DF/wKiom1etNKHxAxE-AAAvfsYSGd8785.png "title=" Picture 5.png "alt=" Wkiom1etnkhxaxe-aaavfsysgd8785.png "/>

[[email protected] ~]# Docker service--help

Commands:create Create a new service inspect Display detailed information on one or more services PS List the tasks of a service LS List services RM Remove A service scale scale one or multiple s ervices Update Update a service

Reference:https://docs.docker.com/engine/swarm/


This article is from the "Network Favorites" blog, so be sure to keep this source http://liyaoyi.blog.51cto.com/442933/1837188

docker1.12.0 Swarm cluster

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.