官术网_书友最值得收藏!

Building a Docker Swarm cluster

Docker introduced swarm mode to its Docker engine from version 1.12.0. Docker Swarm allows us to pool together multiple Docker hosts to deploy our containers in a scalable and high availability way. In this section, we will build a small Docker Swarm cluster.

Let's dive into building our cluster with the following steps:

  1. First, we will go to our Docker host and initialize it as a managermanager is responsible for maintaining the state of our Docker Swarm cluster. It also dispatches tasks to other Docker hosts in our cluster. Let's type the following command to begin the initialization:
dockerhost$ docker swarm init
Swarm initialized: current node (w49smc2ciy100gaecgx77yir3)
is now a manager


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

docker swarm join --token SWMTKN-1-4wbs...aq2r \
172.16.132.187:2377

The preceding command generated a token that will be used by other Docker hosts to join our cluster.

  1. Next, we will go to a new Docker host called node1. We use the token from the previous step to make this Docker host join our Docker Swarm cluster as a worker. Workers are members of the cluster that are responsible for running our containers. Let's now type the following command to make this new node join our cluster:
node1$ docker swarm join --token SWMTKN-1-4...aq2r \ 172.16.132.187:2377
This node joined a swarm as a worker.
We can scale out our Docker Swarm cluster by adding more managers and workers using the same Docker Swarm join command. More details can be found in the upstream Docker documentation at https://docs.docker.com/engine/swarm/join-nodes.

We have now finished setting up our Docker Swarm cluster. Let's go back to our Docker client workstation and confirm the members of our cluster:

client$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
w49smc * dockerhost Ready Active Leader 18.09.0
2e0aif node1 Ready Active 18.09.0
主站蜘蛛池模板: 天气| 五莲县| 巩义市| 丹巴县| 富宁县| 新安县| 大连市| 金堂县| 珲春市| 双鸭山市| 建昌县| 金塔县| 永泰县| 钟山县| 桓仁| 城市| 马鞍山市| 安阳市| 高密市| 汉源县| 民乐县| 天气| 鹿泉市| 巨野县| 习水县| 车致| 乐东| 岢岚县| 海口市| 新兴县| 浮梁县| 安泽县| 宣化县| 麻栗坡县| 隆子县| 驻马店市| 老河口市| 台州市| 武清区| 师宗县| 淄博市|