CentOS7安装Docker Swarm

1、Docker Swarm 初始化

docker swarm init

  Docker Swarm 是基于Overlay网络,官方文档:Docker Swarm 使用的overlay网络

2、开启防火墙端口

# 添加端口:
firewall-cmd --zone=public --add-port=2377/tcp --permanent
firewall-cmd --zone=public --add-port=7946/tcp --permanent
firewall-cmd --zone=public --add-port=7946/udp --permanent
firewall-cmd --zone=public --add-port=4789/udp --permanent

 3、重启防火墙生效

systemctl restart firewalld

 4、查看开放的端口

firewall-cmd --list-ports

5、节点加入集群

docker swarm join --token SWMTKN-1-0ybbwp96xutn0qnj3803h76ix37o9k68nq xxx.xxx.xxx.xxx:2377

This node joined a swarm as a worker.

主节点和工作节点都需要开启防火墙,没有开启会导致节点加入失败:

Error response from daemon: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp xxx.xxx.xxx.xxx:2377: connect: no route to host"

你可能感兴趣的:(服务器)