Step 1) Create AWS EC2 Instance and install docker on it.
Step 2) Initialize swarm cluster using below command
#docker swarm init
or
#docker swarm init --advertise-addr <public/private ip>
Step 3) Worker token auto generate when you initialize the swarm cluster.
If we need to regenerate it use below command.
#docker swarm join-token worker
Step 4) Generate manager token using below command
#docker swarm join-token manager
Step 5)Login on another manager host and execute swarm join command which is generated using above command.
Step 6)If you restarted the server then no need to manually execute the command to rejoin the cluster. It will automatically rejoin the cluster.
Step 7)If you want to re-initialize the swarm cluster follow the below steps.
docker swarm leave --force --> Remove node from old cluster
systemctl stop docker --> stop docker
rm -rf /var/lib/docker/swarm --> remove existing swarm configuration
systemctl start docker --> start docker
docker swarm init --> inititiate new cluster
No comments:
Post a Comment