1、查看节点
bash
root@docker-swarm-manager:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
lzjdu37bi9uwuba2vaeoydyt5 * docker-swarm-manager Ready Active Leader 20.10.17
z80g2c41838egi2fd52dix4ga docker-swarm-node Ready Active 20.10.17
2、Node节点添加标签
bash
docker node update --label-add my-label=tan z80g2c41838egi2fd52dix4ga
3、部署到指定work节点
bash
docker service create --network tankesong_net --name my-nginx -p 8090:80 --replicas 2 --constraint 'node.labels.my-label==tan' nginx
4、查看部署节点
bash
root@docker-swarm-manager:~# docker service ps my-nginx
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
rsiqx8ilkf2n my-nginx.1 nginx:latest docker-swarm-node Running Running 6 minutes ago
wh68pigljqwg \_ my-nginx.1 nginx:latest docker-swarm-node Shutdown Rejected 7 minutes ago "No such image: nginx:latest@s..."
nginx:latest@s..."