Make docker a one node swarm cluster.
docker swarm init
Create an overlay network so multiple stacks can communicate with each other.
docker network create --scope swarm --driver overlay --attachable nats-net
Deploy a new scalable nats stack.
docker stack deploy --compose-file docker-compose-with-bootstrap.yml one
docker stack deploy --compose-file docker-compose-node-only.yml two
Just to note, if you don't set the
endpoint_mode: dnsrr
then the nodes will hit the load balancer when trying to contact the nats-bootstrap service. The problem with this is that the bootstrap instance of nats will see the ip address of nodes as coming form the vip (virtual ip in swarm) rather than it's own ip address.So just set the endpoint_mode to dnsrr which will prevent the load balancer from working.
Also, never scale the bootstrap node. If your first stack needs to be scaled, then scale the nats-node. The bootstrap node is just a central point for nodes when they start up. The load should be shared among the whole cluster.