一旦你们创建了一个带有管理节点的swarm集群,你就可以开始添加 worker节点
$ docker-machine ssh worker1 $ docker swarm join --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c 192.168.99.100:2377 This node joined a swarm as a worker.
你可以在管理节点通过下面命令来获取token
$ docker swarm join-token worker To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c 192.168.99.100:2377
把worker2 节点也加入进来
$ docker-machine ssh worker2 $ docker swarm join --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c 192.168.99.100:2377 This node joined a swarm as a worker.
查看所有节点的信息:(只能在管理节点执行)
$docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 03g1y59jwfg7cf99w4lt0f662 worker2 Ready Active 9j68exjopxe7wfl6yuxml7a7j worker1 Ready Active dxn1zf6l61qsb1josjja83ngz * manager1 Ready Active Leader
manager列留空的是 worker节点
Leader 表示该节点为 manager节点
docker node ls 命令只能在 manager节点才能运行
时间: 2024-10-28 17:44:48