1 00:00:00,001 --> 00:00:01,767 [No Audio] 2 00:00:01,767 --> 00:00:04,734 In this demo, we will perform a few more 3 00:00:04,734 --> 00:00:06,767 orchestration related tasks. 4 00:00:08,167 --> 00:00:12,867 If you remember clearly, our service web-server had 3 replicas 5 00:00:12,867 --> 00:00:18,567 of latest: nginx image. Let's scale our service and 6 00:00:18,567 --> 00:00:22,734 increase its number of replicas to 6. We can do 7 00:00:22,734 --> 00:00:26,334 it with docker service scale command, followed by 8 00:00:26,334 --> 00:00:30,267 the name of service, and the number of replicas. 9 00:00:30,734 --> 00:00:34,034 Once Swarm has verified the scaling, we can do it 10 00:00:34,034 --> 00:00:37,234 as well using docker service ps, followed by the 11 00:00:37,234 --> 00:00:41,201 service name. And as you can see, instead of 3, 12 00:00:41,201 --> 00:00:44,234 now we have 6 containers running on nginx 13 00:00:44,234 --> 00:00:47,067 latest image, 3 of them are scheduled on 14 00:00:47,067 --> 00:00:50,201 manager and 3 of them are scheduled on worker. 15 00:00:50,334 --> 00:00:53,234 All of those 6 are in running state, and 3 16 00:00:53,234 --> 00:00:55,601 of them seem to be quite new. 17 00:00:56,267 --> 00:00:58,134 As you might have expected, 18 00:00:58,134 --> 00:01:00,967 if we run docker ps -a, on both 19 00:01:00,967 --> 00:01:04,434 manager and worker-1, we will see 3 20 00:01:04,434 --> 00:01:06,667 containers running on each of them. 21 00:01:07,401 --> 00:01:12,934 While worker-1 has two new containers, manager has 1 new container. 22 00:01:12,934 --> 00:01:15,967 Furthermore, we can even roll out some 23 00:01:15,967 --> 00:01:19,001 updates on all of these 6 containers. 24 00:01:19,501 --> 00:01:24,734 As you know, all of these containers are running on nginx:latest image, 25 00:01:24,734 --> 00:01:27,801 we can change it to nginx:alpine. 26 00:01:27,801 --> 00:01:30,867 If you're wondering what is the difference? Well, the 27 00:01:30,867 --> 00:01:34,434 latest version of nginx is built on top of 28 00:01:34,434 --> 00:01:38,867 Ubuntu base image, whereas alpine version is based on 29 00:01:38,867 --> 00:01:42,567 top of minimal Alpine Linux image. Let's use the 30 00:01:42,567 --> 00:01:45,567 command docker service update followed by what 31 00:01:45,567 --> 00:01:48,667 kind of field do we want to update. We want to 32 00:01:48,701 --> 00:01:52,001 update the image of the service. Once we hit 33 00:01:52,001 --> 00:01:56,467 enter, all of these tasks get updated one at a time. 34 00:01:56,467 --> 00:01:59,434 Once the update process is complete, we can 35 00:01:59,434 --> 00:02:02,667 verify it with docker service inspect command 36 00:02:02,667 --> 00:02:05,634 and let's make sure that the result of the inspect 37 00:02:05,634 --> 00:02:09,567 command is pretty printed. As you can see, the 38 00:02:09,567 --> 00:02:12,167 service mode is still replicated, the number of 39 00:02:12,167 --> 00:02:15,367 replicas is 6. If we go to the container 40 00:02:15,367 --> 00:02:19,534 specification, instead of showing nginx:latest, it 41 00:02:19,534 --> 00:02:22,767 shows nginx:alpine, which means all of the 42 00:02:22,767 --> 00:02:25,934 containers are switched from nginx:latest to 43 00:02:25,934 --> 00:02:29,567 alpine image. Finally, we can remove our service 44 00:02:29,567 --> 00:02:32,601 using docker service rm command followed by the 45 00:02:32,601 --> 00:02:37,467 name of the service. And as a notification, we get 46 00:02:37,467 --> 00:02:41,834 the name of service. Let's type docker ps -a, 47 00:02:41,834 --> 00:02:45,434 and as you can see, every container is being 48 00:02:45,434 --> 00:02:50,134 taken down one by one. If we do the same on worker-1 node, 49 00:02:50,134 --> 00:02:52,734 you will see that all of the containers 50 00:02:52,734 --> 00:02:56,467 are taken down and also removed. Let's wait for a 51 00:02:56,467 --> 00:03:00,001 while and use the same command on manager as well. 52 00:03:00,434 --> 00:03:03,934 Well, now even our manager is empty. 53 00:03:04,234 --> 00:03:08,967 Finally, let's clean up our cluster by making sure that 54 00:03:08,967 --> 00:03:13,067 worker node is also leaving the cluster. Just like 55 00:03:13,067 --> 00:03:17,101 we did with worker-2, we will also make worker-1 56 00:03:17,101 --> 00:03:21,067 leave the cluster voluntarily using docker swarm leave command. 57 00:03:21,067 --> 00:03:25,701 We are back to having one Docker Host which is manager.