Wednesday, 24 July 2019

How to install Docker Swarm by Raj Gupta

Take 3 amazon EC2 server in which we are going to make one server as master and reaming two server  as worker

Note:-  docker mast be already install in all the server



keep all machine in same network so that they are able to ping each other

Master:-

[root@ip-172-31-40-90 ~]# docker info
Swarm: inactive

[root@ip-172-31-40-90 ~]# docker swarm init
Swarm initialized: current node (rby7qdb8hc3ebuuy78vpl0i4v) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-4z0bipbsxzoy2ccn5m22eiems1w0a5du8rlyt6nbvdq3pfegm8-1z76g4wwivmk1s0cp8dethxav 172.31.40.90:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

[root@ip-172-31-40-90 ~]# docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
rby7qdb8hc3ebuuy78vpl0i4v *   ip-172-31-40-90     Ready               Active              Leader              18.06.1-ce
[root@ip-172-31-40-90 ~]#

After running the above red mark command on all worker 

[root@ip-172-31-40-90 ~]# docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
q0yqpe0fsihtmoaj1834s1tnf     ip-172-31-35-189    Ready               Active                                  18.06.1-ce
rby7qdb8hc3ebuuy78vpl0i4v *   ip-172-31-40-90     Ready               Active              Leader              18.06.1-ce
pzcz2fs38ks9vrwecn30txuv9     ip-172-31-43-91     Ready               Active                                  18.06.1-ce
[root@ip-172-31-40-90 ~]#

So both the node are added with master as worker

[root@ip-172-31-40-90 ~]# docker info
Swarm: active


Worker01:-

[root@ip-172-31-35-189 ~]# docker info
Swarm: inactive

[root@ip-172-31-35-189 ~]#  docker swarm join --token SWMTKN-1-4z0bipbsxzoy2ccn5m22eiems1w0a5du8rlyt6nbvdq3pfegm8-1z76g4wwivmk1s0cp8dethxav 172.31.40.90:2377
This node joined a swarm as a worker.
[root@ip-172-31-35-189 ~]#

[root@ip-172-31-35-189 ~]# docker info
Swarm: active


Worker02:-

[root@ip-172-31-43-91 ~]# docker info
Swarm: inactive

[root@ip-172-31-43-91 ~]# docker swarm join --token SWMTKN-1-4z0bipbsxzoy2ccn5m22eiems1w0a5du8rlyt6nbvdq3pfegm8-1z76g4wwivmk1s0cp8dethxav 172.31.40.90:2377
This node joined a swarm as a worker.
[root@ip-172-31-43-91 ~]#

[root@ip-172-31-43-91 ~]# docker info
Swarm: active




No comments:

Post a Comment