Docker Swarm
Firewall Settings
In order to add the necessary firewall rules, check docs from docker.
The following are necessary:
- TCP port
2377for cluster management communications - TCP and UDP port
7946for communication among nodes - UDP port
4789for overlay network traffic
Initializing Swarm
On the leader:
PUBLICIP=$(curl -sSL 'https://api.ipify.org?format=txt')
docker swarm init --advertise-addr $PUBLICIP
To generate manager tokens:
docker swarm join-token manager
To join:
PUBLICIP=$(curl -sSL 'https://api.ipify.org?format=txt')
docker swarm join XXXXXXXXXXXXXX:2377 --advertise-addr $PUBLICIP
To change node name before joining:
sudo hostnamectl set-hostname XXXXX
sudo systemctl restart docker