swarm-master-01 = 192.168.0.150
swarm-node-01 = 192.168.0.151
swarm-node-02 = 192.168.0.152
swarm-master-01
yum install docker
systemctl disable firewalld
systemctl stop firewalld
docker swarm init --advertise-addr 192.168.0.150
#after this command it will genrate join command
docker swarm join --token SWMTKN-1-3xrfrgwy67vm0dmel94fveuqvg9ngsv8qt5jysl31xfv16c0gq-55tzlxjtezu59l4mw4hxjo3h9 192.168.0.150:2377
On swarm-node1,2
yum install docker
systemctl disable firewalld
systemctl stop firewalld
docker swarm join --token SWMTKN-1-3xrfrgwy67vm0dmel94fveuqvg9ngsv8qt5jysl31xfv16c0gq-55tzlxjtezu59l4mw4hxjo3h9 192.168.0.150:2377
Install swarm dashboard
https://github.com/charypar/swarm-dashboard
# compose.yml
version: "3"
services:
dashboard:
image: charypar/swarm-dashboard
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- 8080:8080
environment:
PORT: 8080
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
#deploy swarm dashboard
docker stack deploy -c compose.yml svc
#Dashboard will be accessible on http://master_ip:8080
Deploy service in swarm cluster
docker service create -p 8881:80 --name httpd --replicas 2 httpd