Wednesday, 21 August 2019

Docker service(scale,port mapping) Part-3 by Raj Gupta


on master
[root@ip-172-31-83-166 ~]# docker service create -d --replicas 2 alpine ping 172.31.83.166
uz034gaq968jxsriuuob4lxsa
[root@ip-172-31-83-166 ~]#

on worker02
[root@ip-172-31-83-166 ~]# docker service create -d --replicas 3 alpine ping 172.31.81.43
wkk7l8bacrrld2qaupubdr0m2
[root@ip-172-31-83-166 ~]#


[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
uz034gaq968j        laughing_rosalind    replicated          2/2                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest
befib2ehy1bk        optimistic_kilby     replicated          4/4                 alpine:latest
wkk7l8bacrrl        sharp_hawking        replicated          3/3                 alpine:latest
[root@ip-172-31-83-166 ~]#


now to increase and decrease replicas

[root@ip-172-31-83-166 ~]# docker service scale wkk7l8bacrrl=7
wkk7l8bacrrl scaled to 7
overall progress: 7 out of 7 tasks
1/7: running   [==================================================>]
2/7: running   [==================================================>]
3/7: running   [==================================================>]
4/7: running   [==================================================>]
5/7: running   [==================================================>]
6/7: running   [==================================================>]
7/7: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]#


At same time

[root@ip-172-31-83-166 ~]# docker service scale wkk7l8bacrrl=5 befib2ehy1bk=8
wkk7l8bacrrl scaled to 5
befib2ehy1bk scaled to 8
overall progress: 5 out of 5 tasks
1/5: running   [==================================================>]
2/5: running   [==================================================>]
3/5: running   [==================================================>]
4/5: running   [==================================================>]
5/5: running   [==================================================>]
verify: Service converged
overall progress: 8 out of 8 tasks
1/8: running   [==================================================>]
2/8: running   [==================================================>]
3/8: running   [==================================================>]
4/8: running   [==================================================>]
5/8: running   [==================================================>]
6/8: running   [==================================================>]
7/8: running   [==================================================>]
8/8: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]#

[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
uz034gaq968j        laughing_rosalind    replicated          2/2                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest
befib2ehy1bk        optimistic_kilby     replicated          8/8                 alpine:latest
wkk7l8bacrrl        sharp_hawking        replicated          5/5                 alpine:latest
[root@ip-172-31-83-166 ~]#


Now to remove service 

[root@ip-172-31-83-166 ~]# docker service rm befib2ehy1bk wkk7l8bacrrl
befib2ehy1bk
wkk7l8bacrrl
[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
uz034gaq968j        laughing_rosalind    replicated          2/2                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest
[root@ip-172-31-83-166 ~]#


-------------------------------------------------------------------------------------------------------------

Port mapping:-

[root@ip-172-31-83-166 ~]# docker service create -d -p 8090:80 nginx
r3emkkfmh4a37wuxrneh0ovru
[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
r3emkkfmh4a3        tender_chaplygin    replicated          1/1                 nginx:latest        *:8090->80/tcp
[root@ip-172-31-83-166 ~]#


now you are able to access it from any nodes(master,worker01,worker02)
http://54.210.168.62:8090/


1 comment:

  1. Hello everyone , here’s your opportunity for you to achieve your dreams of being a multi million dollar rich through trading , I once loss all I got through trading but was fortunate to come across a woman with great virtue and selfless heart (Mary ) i was introduce to her masterclass strategy while searching online which has revived me of all my losses and made me gain more and more . With her unique strategy you are entitled to daily signals and instant withdraw ,be rest assured of getting a refund of all your loss investment with any platform that has denied you in one way or the other in getting your money . Mrs Mary masterclass strategy is simply the best for beginners and those that are finding it difficult to succeed through trading she’ll help you with just a simple step . Email her ( maryshea03 @ Gmail .com) WhatsApp +1 562 384 7738 . Remember this is absolutely free!!!

    ReplyDelete