Options: --advertise-addr string Advertised address (format: "<ip|interface>[:port]") --autolock Enable manager autolocking (requiring an unlock key to start a stopped manager) --availability string Availability of the node ("active", "pause", "drain") (default "active") --cert-expiry duration Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s) --data-path-addr string Address or interface to use for data path traffic (format: "<ip|interface>") --data-path-port uint32 Port number to use for data path traffic (1024 - 49151). If no value is set or is set to 0, the default port (4789) is used. --default-addr-pool ipNetSlice default address pool in CIDR format (default []) --default-addr-pool-mask-length uint32 default address pool subnet mask length (default 24) --dispatcher-heartbeat duration Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s) --external-ca external-ca Specifications of one or more certificate signing endpoints --force-new-cluster Force create a new cluster from current state --listen-addr node-addr Listen address (format: "<ip|interface>[:port]") (default 0.0.0.0:2377) --max-snapshots uint Number of additional Raft snapshots to retain --snapshot-interval uint Number of log entries between Raft snapshots (default 10000) --task-history-limit int Task history retention limit (default 5)
执行 docker swarm init 带上 master 节点的 IP 地址
1 2 3 4 5 6 7 8
# docker swarm init --advertise-addr=192.168.1.112 Swarm initialized: current node (oy7rs34fbjue71hq8k5gtlelo) is now a manager.
To add a worker to this swarm, run the following command:
# docker swarm join --token SWMTKN-1-1pq9zqbgvm6o50th0pxbywai971805s9fu4fiw4cnejn0jnzv6-aajxxekc40t7c1o6ofpt8rlgj 192.168.1.112:2377 This node joined a swarm as a worker. 这个是打印出来的
加入完毕之后 可以 使用 ocker node ls 命令查看集群里面的服务器信息。
1 2 3 4 5 6 7 8
# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION oy7rs34fbjue71hq8k5gtlelo * swarm-master Ready Active Leader 24.0.5 这台是master节点,hostname那个列显示了主机名。 5dcuxo3b2hhgf2rhlf3fpcpun swarm-work1 Ready Active 24.0.5 i870enyo9md194jvwl73fnqfn swarm-work2 Ready Active 24.0.5 69bet6xtvm9361w5cv2uac5xf swarm-work3 Ready Active 24.0.5