- [Instructor] As an administrator
of a Docker Swarm cluster,
it's important to be able to quickly investigate
what's happening in Docker Swarm
and also if possible, be able to visual
what's happening in the swarm cluster.
For example, if we use the command docker node space ls,
you can see that for this video,
I've added a third node
to our Docker Swarm cluster.
So we actually have three nodes now
in the Docker Swarm cluster
and all three of these nodes are manager nodes.
One of those managers is the leader
of the Docker Swarm cluster.
So the docker node ls command
is very useful in learning about what's going on
in the cluster.
You can also do docker info
and we'll pipe that to more
and this will give us some more information
on what's happening in the swarm cluster.
You can see the node ID,
you can see that this node
is indeed a manager,
that there are three managers
in this cluster and there are three nodes
in the cluster as well.
So docker info is a useful command
when it comes to investigating
what's happening in the cluster.
But now I'd like to show you another tool
that can help you to visualize
what's going on in the Docker Swarm cluster.
In fact, we're going to perform
a live demonstration of how Docker Swarm
can help you to achieve high availability
with your workloads
in the event that one of your Docker Swarm node
has a failure.
We're here on GitHub
at the docker samples repository
and there's a very cool tool in here
called Docker Swarm Visualizer.
And if we scroll down you can see
what this tool might tell us.
It helps us to visualize
what's going on in the cluster.
In this graphic, they have four nodes
and they have a number of workloads
running across those four nodes.
So it tells us down here the exact instructions
we need to run the Docker Swarm Visualizer.
So I'm just going to copy that docker run command line
which will download the Docker Samples Visualizer
from GitHub and let's go back
to the command line on our docker nodes
and we're actually going to go to
node two of the cluster
and we're going to paste in that command line
to deploy our startup,
this docker container to run the Docker Swarm Visualizer.
Alright, so let's do a docker PS
and we can see the Docker Samples Visualizer is running here
and oh by the way, there's a number of other containers
running on this docker host.
What's that all about?
So let me show you what I've done.
If we run Docker service space LS,
I've created a docker service called Web App One
that's made up of 10 replicas
of the Nginx web server.
So I've told Docker Swarm to deploy this service
across the cluster of three nodes
and ensure that 10 replicas are always running
of this Nginx web server
that's running inside a container.
So if we do a docker space PS
we actually have five of those containers
running on this host.
This is node two.
If we go over to node one
and do a docker space PS
there are no containers running on this host
and let's go check host three
with a docker PS.
Here are five more Nginx web server containers
that are part of that web app service.
With the Docker Swarm Visualizer deployed and running
let's go back to that host two
where we deployed it
and notice here that's it's going to be running
on port 8080 of this host.
So if we get the IP address of this host
I'll do an IP adder and I'll scroll up to the top here.
We'll just copy the IP address
for this host and remember to add on
8080 at the end.
We'll open a new tab,
paste in that IP address.
We'll add colon 8080 at the end,
and here we go.
Here's the Docker Swarm Visualizer,
that's running on our Docker Swarm cluster.
So we have the three nodes,
node one, node two,
and node three.
All three of these are managers,
they have identical configuration,
two gigs of RAM.
They're 64 Bit LINUX host,
and then we have this web app down here that's running.
And this web app called Web App One
is a service and we told it to
ensure that there are always 10 replicas
of the web app.
So if we count these out,
I count exactly five running on
each of the two nodes.
So now what we're going to do
is to shut down the docker service
on node three.
We don't want to shut it down on node two
because that's actually where the visualizer container
is running.
So we're going to stop the docker service
on node three
and then watch what happens
in the Docker Swarm Visualizer.
On node three, we'll do a sudo systemctl stop docker.
I'll do a docker node ls
and the docker demon is indeed stopped.
Back at the visualizer,
you can see that there is a red dot here
on node three.
Something's not quite right.
Let's give it a second to update.
It looks like node three's down.
Those workloads have gone away
and oh, look what happened right there.
Those five containers
that were running on node three
magically thanks to swarm
and the swarm service that we defined,
restarted those five containers.
They were on node three
which had a simulated failure
over on node one
to ensure that there were always 10 replicas
of the web app running across our docker cluster.
So this is just an example of how we can investigate
and visualize what's happening in Docker Swarm
and see a real world example
if you had a failure,
on a particular node,
Docker Swarm would ensure that
the containers that were running on that node,
are automatically restarted
on another node in the Docker Swarm cluster.