Docker Swarm Setup
Docker Swarm Setup
1. apt-get update
2. apt-get install docker.io on all servers
3. sudo docker swarm init ---on manager node to initialize the swarm.
THe output of the above command will give a docker swarm join command
eg. docker swarm join --token SWMTKN-1-
0tptbzdpaaj11m4vhscjnarctx2sn8zwzmcyjgs2wzu1bq73st-2fpy9ttoqusd17msygffk6bus
172.31.33.118:2377
2377 is the port on worker node on which the worker nodes will connect.
Hence make sure SG of the manager node allws 2377 port to all workers
4.Install and start docker on workers and run the docker swarm join token...
command
THis way all workers will get connected to the manager
5. Now on the manager we will run a service using the following command.
sudo docker service create --name react_todo --replicas 2 --publish 8001:8001
trainwithshubham/react-django-app:latest
version: '3.7'
services:
reactapp:
image: trainwithshubham/react-django-app:latest
ports:
- "8001:8001"
mysqldb:
image: mysql:latest
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: test123