Install docker on Master and worker node and master node execute docker swarm init command.
[root@ip-172-31-34-29 ~]# docker swarm init
Swarm initialized: current node (xk88ov6mds5qdmzaj2obkfwyp) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-58apbdwqjurmocvp1mlbgu85w8340g8beh65ztuvjw43x30cqp-bqthz5iqs32vtu0tiuc6efqhr 172.31.34.29:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
Add worker node and manager in swarm cluster.
docker swarm join-token worker
docker swarm join-token manager
Remove manager and worker node:
docker swarm leave
#docker node ls ==> to check swarm cluster node details.
===============
v2.16.0
sudo curl -L "https://github.com/docker/compose/releases/download/{v2.16.0}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
step-1) Create 2 node
step 2) One master and one worker
step 3) make sure docker installed on both the host.
step 4) #docker --version
step 5) execute below commands on master node
#docker swarm init
step 6) execute below command on worker node:
docker swarm join --token SWMTKN-1-58apbdwqjurmocvp1mlbgu85w8340g8beh65ztuvjw43x30cqp-bqthz5iqs32vtu0tiuc6efqhr 172.31.34.29:2377 ==> PLease check docker swarm init command output.
step 7) execute below commands on master node:
#docker node ls
#docker run -it -d -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer
(https://github.com/dockersamples/docker-swarm-visualizer)
step 8) create yml file and deplyo it in swarm cluster.
[root@master ~]# cat sample.yml
version: '3'
services:
bb-app:
image: nginx
ports:
- "8000:3000"
docker stack deploy -c sample.yml demo
=========================================
docker swarm init add what you get to worker node --open the port
docker node ls
docker service ls
docker run -it -d -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer
docker ps -a
docker service create --name nginxweb -p 8081:80 nginx
docker service create --name nginxweb1 -p 8082:80 --replicas 5 nginx
docker service ps nginxweb1
docker service scale nginxweb1=7
docker service scale nginxweb1=1
docker node update --availability drain docker
docker node update --availability active docker
docker node ls
No comments:
Post a Comment