Join a Docker Swarm node running on Google Compute Engine

Since Google Compute virtual machine will be behind a nat network, you have to pass to the join command the “advertise” ip address.

Without it the node will be added in any case, but the overly network won’t work (because the system will try to contact the virtual machine through its local address):

sudo docker swarm join \
  --token SWMTKN-1-qwe...... \
  # here your public IP
  --advertise-addr 1.2.3.4 \
  2.3.4.5:2377