Install required packages
yum install yum-utils lvm2 device-mapper-persistent-data
Add Docker-Repository
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install Docker-CE
yum install docker-ce
Add regular user to docker group (allows user to exec docker commands without sudo)
usermod -aG docker user
Enable service for autostart and start docker
systemctl enable docker && systemctl start docker
Configure firewall for Docker Swarm
firewall-cmd --permanent --add-port=2376/tcp
firewall-cmd --permanent --add-port=2377/tcp
firewall-cmd --permanent --add-port=7946/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=7946/udp
firewall-cmd --permanent --add-port=4789/udp
Restart Firewall and Docker
systemctl restart firewalld
systemctl restart docker
Init the swarm on the manager
docker swarm init --advertise-addr <MANAGER-IP>
Show master or worker tokens
docker swarm join-token worker
docker swarm join-token manager
Join swarm
docker swarm join --token <TOKEN> <MANAGER-IP>:2377
Start simple docker swarm service
docker service create -p 80:80 --name webservice --replicas 2 httpd
Show status
docker service ls
Check logs from all swarms nodes
docker service logs webservice
Scale service
docker service scale webservice=3