[No Audio]
In this demo, we will perform a few more
orchestration related tasks.
If you remember clearly, our service web-server had 3 replicas
of latest: nginx image. Let's scale our service and
increase its number of replicas to 6. We can do
it with docker service scale command, followed by
the name of service, and the number of replicas.
Once Swarm has verified the scaling, we can do it
as well using docker service ps, followed by the
service name. And as you can see, instead of 3,
now we have 6 containers running on nginx
latest image, 3 of them are scheduled on
manager and 3 of them are scheduled on worker.
All of those 6 are in running state, and 3
of them seem to be quite new.
As you might have expected,
if we run docker ps -a, on both
manager and worker-1, we will see 3
containers running on each of them.
While worker-1 has two new containers, manager has 1 new container.
Furthermore, we can even roll out some
updates on all of these 6 containers.
As you know, all of these containers are running on nginx:latest image,
we can change it to nginx:alpine.
If you're wondering what is the difference? Well, the
latest version of nginx is built on top of
Ubuntu base image, whereas alpine version is based on
top of minimal Alpine Linux image. Let's use the
command docker service update followed by what
kind of field do we want to update. We want to
update the image of the service. Once we hit
enter, all of these tasks get updated one at a time.
Once the update process is complete, we can
verify it with docker service inspect command
and let's make sure that the result of the inspect
command is pretty printed. As you can see, the
service mode is still replicated, the number of
replicas is 6. If we go to the container
specification, instead of showing nginx:latest, it
shows nginx:alpine, which means all of the
containers are switched from nginx:latest to
alpine image. Finally, we can remove our service
using docker service rm command followed by the
name of the service. And as a notification, we get
the name of service. Let's type docker ps -a,
and as you can see, every container is being
taken down one by one. If we do the same on worker-1 node,
you will see that all of the containers
are taken down and also removed. Let's wait for a
while and use the same command on manager as well.
Well, now even our manager is empty.
Finally, let's clean up our cluster by making sure that
worker node is also leaving the cluster. Just like
we did with worker-2, we will also make worker-1
leave the cluster voluntarily using docker swarm leave command.
We are back to having one Docker Host which is manager.