# 初使化Swarm 192.168.1.1为对外IP
docker swarm init --listen-addr 192.168.1.1:2377 --advertise-addr 192.168.1.1
# 查看Worker Token
docker swarm join-token worker
# Worker加入集群 替换对应token值
docker swarm join --token \
SWMTKN-1-5eukghd8e9wby5aw8t8y4rdz425euoo8m9qgmgitpxg63ax2ol-94dvz9vrx5oai22jc3vl2eh56 \
192.168.1.1:2377
# 查看Manager Token
docker swarm join-token manager
# Manager加入集群 替换对应token值
docker swarm join --token \
SWMTKN-1-5eukghd8e9wby5aw8t8y4rdz425euoo8m9qgmgitpxg63ax2ol-94dvz9vrx5oai22jc3vl2ehed2 \
192.168.1.1:2377
# 查看集群中的节点 在Manager机器人执行
docker node ls
# 创建虚拟网络
docker network create --driver overlay --subnet 10.0.10.0/24 \
--opt encrypted test_network
# Centos 7 防火墙开放端口
firewall-cmd --add-port=2376/tcp --permanent
firewall-cmd --add-port=2377/tcp --permanent
firewall-cmd --add-port=7946/tcp --permanent
firewall-cmd --add-port=7946/udp --permanent
firewall-cmd --add-port=4789/udp --permanent
sudo firewall-cmd --reload