Skip to main content

Docker Swarm

Firewall Settings

In order to add the necessary firewall rules, check docs from docker.

The following are necessary:

  • TCP port 2377 for cluster management communications
  • TCP and UDP port 7946 for communication among nodes
  • UDP port 4789 for 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