Ok let me drop down what i did here to setup this docker swarm without repeating since i have been very indecisive on whether to deploy multi-host docker swarm or just single location with fail over between multiple machines. In the end, i stick with single region and expand from here if needed.
Machines Setup
Installing Dockers
throw these in each machine
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo apt-key fingerprint 0EBFCD88 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update sudo apt-get install docker-ce -y
doing this gives us the latest docker setup
Installing Docker Swarm
Now i need to setup docker swarm, its pretty straight forward with the following command on the master machine
docker swarm init --advertise-addr 192.168.10.10
then on other worker machine do the following to add them into swarm,
docker swarm join --token secret-token 192.168.10.10:2377
replace your secret-token with the real deal. Now i'm gonna secret our network a bit with overlay with the name overnet
docker network create --opt encrypted --driver overlay --attachable overnet
this doesn't make you feel any differences but it creates an overlay network between each node in the swarm.
Installing reverse proxy for docker swarm
now i need to create a reverse proxy for my docker swarm since i wants to do a lot with it.
docker service create \ --name traefik \ --constraint=node.role==manager \ --publish 80:80 \ --publish 8080:8080 \ --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ --network overnet\ traefik:latest \ --docker \ --docker.swarmmode \ --docker.domain=traefik \ --docker.watch \ --web
for more information on this, you can visit traefik web page for more information on its configuration.