the setup is easy, actually. we only need to have 2 linux machines with docker installed.
-
we execute this command on the first machine:
docker swarm init
or if you have multiple interfaces with multiple ip's you get error when you wanna init the cluster, you should choose one interface/ip and init using that address as --advertise-addr, like this:
docker swarm init --advertise-addr masterip
which outputs a join command for the worker node to join the swarm cluster:
docker swarm join --token mytoken masterip:2377
-
check if the node(s) have successfully joined the cluster.
docker node ls
-
deploy the tomcat stack on the cluster.
docker stack deploy -c stack.yaml tomcat-stack
-
check status of services and containers of tomcat-stack in the cluster with these two commands.
docker stack services tomcat-stack
docker stack ps tomcat-stack
-
profit.