Hey guys welcome back this is Bernardo from the BTNHD and today is all about building
a Docker swarm, and let's get into it.
Okay, so I'm getting myself into the Docker world and the more I'm learning the more I'm
pushing out these videos to you guys so I learned how to build a Docker swarm, and I'm
going to show you what I've done so far with in my environment so within my environment
I created four machines.
I'm using VMware Workstation 15.
I have two managers and two worker bees all four machines are running lubuntu 20 point
zero for all four machines I install SSH server on it.
I enabled the firewall on all four machines so I'm able to putty into each machine rather
than going inside the virtual machine right as you can see on the screen, I am inside
the manager one, manager two, worker one, and worker two.
Now on manager one.
All four machines have Docker.
So manager one I'm running Docker version 19.03.11.
The same thing with manager two.
Same thing with worker one and worker two, so all four of these machines have the same
Docker version.
Now the first command that we are going to do on the manager server would be the following,
and just make sure that you add the parameters of advertise address, and also the listen
address.
Now the advertise address and the listen address should be the IP address of your manager.
Okay, once you enter this particular command, you're going to hit enter.
Once you hit enter, it's going to initialize the swarm, and you're done.
It's going to give you a command line to add a worker to the swarm, and that's what you
need to enter.
Now if you're entering another manager into this swarm, you need to run this particular
command, and you hit enter and it's going to actually give you the command plus the
token that you need to add to the additional manager.
So what I'm going to do is copy that entire line.
And I'm going to go inside manager two.
And I'm going to paste it.
Now before you hit enter, we need to add the two additional parameters we need to add the
parameter of advertise address with the manager two IP address, and with the parameter of
listen address with the IP address of the second manager, once you hit enter, then that
manager server is now added it to the swarm as a manager so now I have two managers now
we need to add the worker machines into the swamp, because right now we only have two
managers right, we got manager O one and manager O two the primary manager O one.
So let's go back inside the manager console, we're going to copy that command that allows
me to add a worker within the swarm,
and we're going to go inside the worker O one machine, and we're going to pace it when
you copy the command, make sure you add the parameters of advertise address with the IP
address of the worker machine, and also the parameter of listen address with the IP address
of the worker machine, hit enter, bam, the worker machine is added to the swarm, the
last thing that we need to do is go inside our second worker machine, add that command
line, and again, make sure you add the parameters of advertise address, change the IP address,
and also the parameter of listen to address with the IP address of the second machine.
Once you do that hit Enter, and that machine is now added to the swarm as a worker machine.
Now within the management console, if I run the following command or sudo Docker info.
It gives me information of everything.
And if you look close right here.
The Swarm is active.
And I have two managers, right and now I have four nodes, I have four nodes because manager
01, 02 worker O one and O two are considered nodes within the swarm infrastructure, if
you also take a look here within the manager address I have two of them.
131 is manager o one, and 130 to is manager 02 now if I run the following command of sudo
Docker node. ls it gives me a list of all the machines within the swarm.
And as you can see, everything is ready.
availabilities are active, the manager status right now like manager O one is the leader
and manager 02 is reachable right because that is my my secondary manager, and then
worker O1 and O2, no status because they're just the workers within the swarm infrastructure
let's pull an operating system within our Docker system.
So I'm going to run the following command of sudo Docker pull ubuntu.
Because that is the image that I want to pull, there's actually four layers within this image,
three of them already completed and the last one just got to wait until it's done once
it's completed you're good to go.
Now I'm going to run a sudo Docker images to see the image.
Awesome.
And then I'm going to run the following command to create a container so we are going to do
a sudo Docker run with a parameter name, we're going to give our container a name, and we
are going to do a parameter of it ubuntu.
So we're going to do an interactive console to ubuntu which is the image.
Once you hit enter, you're going to see that your command prompt is going to change this
command prompt indicates that you are now inside the container so if I run a LS with
a parameter, L and that shows the directory of the ubuntu container, if I do a Ctrl C
to get out of it, it takes me back inside the manager console, if I do a command of
sudo docker ps, it gives me a list of all the running containers, which is the container
that we created, and that's it guys hopefully you guys enjoyed this video make sure to hit
that like button also do not forget about punch, elbow and smashing that subscribe button
to get the latest and greatest from this guy.
I'm having a lot of fun dealing with Docker hopefully you guys are enjoying the videos
and I'll catch you guys on the next one.
Peace out.