- [Instructor] One of the great things
about setting up Docker swarm is
that it's amazingly easy to set up and configure.
You'll find the full instructions
for Docker swarm here in the Docker documentation,
but we don't even have to look up the command
to create a Docker swarm cluster.
Let's go over to our first Docker node in the cluster
and we'll initialize our Docker swarm cluster
in a single command.
To set up a Docker swarm cluster,
you use the command Docker swarm init.
So, let's try that command.
Docker swarm space init
and it tells us swarm mode has been initialized.
This node is now a manager.
To add a worker to this node,
you can copy the URL right here
and take that over to another Docker node
that you want to join this swarm cluster.
If you want to add a redundant manager
to this Docker swarm cluster,
you can get the Docker swarm join token
for new manager nodes using this command.
So, with that we've created our Docker swarm cluster.
If we do a docker node ls, we can quickly see the status
of the Docker swarm cluster.
You can see the hostname for this node
that we're on right now.
The node is ready.
The availability for this node is active.
And, this node is the leader of the Docker swarm cluster.
So, now let's add a second node to our cluster.
Let's do the Docker swarm command here
and to get the join tokens for the worker node
if we didn't copy the command line from above
where it did provide the join token
and the full Docker swarm join command,
we simply use Docker swarm join token
and we do have to provide at the end
of that either worker or manager.
So, the full command there is
Docker swarm join-token space worker.
And this is the join token that we need to copy.
So, let's just copy that join token
and then we'll go over to the second node
in our cluster and we'll simply paste that join token in
and there we go.
It tells us this node has joined a swarm as a worker.
If we go back to the first node,
let's clear the screen.
And let's do a Docker node ls.
Here we can see that we now have two nodes in the cluster.
They're both ready.
They're both active,
but only one of them is a manager.
So, that's how easy it is to set up a Docker swarm cluster.