Setting Up a Docker Swarm Cluster on Centos - saviovettoor/DevOps-wiki GitHub Wiki

Complete the setup of a swarm mode cluster, with managers and worker nodes on Centos

  • Docker Installation- Centos

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ##CE since community edition(EE for enterprice)
yum update -y
yum install docker-ce -y
systemctl enable docker && systemctl start docker && systemctl status docker
  • Granting non privilage user savio to run docker command (/var/run/docker.sock)

#adding the user to docker group
usermod -aG docker savio
Then logout and login
  • Docker Swarm Cluster Setup

#Intiate swarm cluster
master]#docker swarm init --advertise-addr <LocalIP> --listen-addr <LocalIP>:2377
	--advertise-addr is the IP and port that other nodes should use to connect to this manager.
	--listen-addr The node listens for inbound swarm manager traffic on this address. The default is to listen on 0.0.0.0:2377.
worker]#docker swarm join --token <WorkerToken> <LocalIP>:2377	

List out the cluster nodes

docker node ls

Lost manager token?

docker swarm join-token manager

Lost worker token?

docker swarm join-token worker
⚠️ **GitHub.com Fallback** ⚠️