-: In the last section,
we downloaded and installed Docker for Windows
or Docker for Mac on your personal computer.
You should now be able to ran the command Docker version
at the command line
and see a little bit of text like this appear.
I now want to write out
our very first kind of meaningful command
with the Docker client or the Docker CLI.
We're going to run a very quick command here,
and then we're gonna go
through a very specific flow of actions that occurred
when that command got executed.
So, here's the command.
We're gonna write docker run hello-world.
Yes, it is kind of a hello world thing of sorts.
Don't worry, it's gonna be rather interesting.
I'll then press enter,
and we're gonna very quickly see
a lot of text start to scroll along the screen.
Now, I'm gonna scroll up a little bit
and you'll see
a little hello from Docker message right here.
And then you'll notice underneath that
it list out these series of steps that just occurred
when you ran that command.
Now, we're going to go over the series of steps right here
in great detail.
So, if you want to,
you can kind of ignore that text for right now.
I'm gonna scroll up a little bit further
and I want you to see up here it says,
"Unable to find image hello world locally."
All right, so with that mind,
let's go take a look at a couple of diagrams
that are gonna help explain what just occurred
when we run that command.
All right, here we go.
So, at the Terminal,
you and I executed the command, docker run hello-world.
That starts up that Docker client or the Docker CLI.
Again, the Docker CLI
is in charge of taking commands from you,
kind of doing a little bit of processing on them,
and then communicating the commands
over to something called the Docker server.
And it's that docker server that is really in charge
of the heavy lifting.
When we ran the command, docker run hello-world,
that meant that we wanted to start up a new container
using the image with the name of hello world.
The hello world image
has a tiny little program inside of it
whose sole purpose, sole job,
issue print-out the message that you see right here.
That's the only purpose of that image.
Now, when we ran that command
and it was issued over to the Docker server,
a series of actions very quickly occurred in the background.
The Docker server
saw that we were trying to start up a new container
using an image called hello world.
The first thing that the Docker server did
was check to see if it already had a local copy.
Like a copy on your personal machine
of the hello world image or that hello world file.
So, the Docker server
looked into something called the ImageCash.
Now, because you and I just installed Docker
on our personal computers,
the ImageCache is currently empty.
We have no images that have already been downloaded before.
So, because the ImageCache was empty,
the Docker server decided to reach out
to a free service called Docker Hub.
The Docker Hub is a repository of free public images
so you can freely download and run
on your personal computer.
So, Docker server reached out to Docker Hub and said,
"Hey, I'm looking for an image called hello world.
Do you have one?"
Of course, the Docker hub does.
So, Docker server downloaded this hello world file
and stored it on your personal computer in this ImageCache
where it can now be reran
at some point in the future very quickly
without having to re-download it from the Docker Hub.
So, essentially, we downloaded it over here like some.
After that, the Docker server then said,
"Okay, great. I've got this image
and now, it's time to use it
to create an instance of a container."
And I remember
what we just said about a container a moment ago.
An instant container is an instance of an image.
Its sole purpose is to run one very specific program.
So, the Docker server
then essentially took that single file,
loaded it up into memory,
created a container out of it,
and then ran a single program inside of it.
And that single program's purpose
was to print out the message that you see right here.
So, that's pretty much it.
That's what happens when you run this Docker run command.
It reaches out to Docker Hub,
it grabs the image,
and then it creates a container out of that image.
Now, one thing that you'll notice that's kind of interesting
if we run the docker run hello-world command a second time,
you'll notice that we are not going to see the message
of downloading or container image not found locally
that we saw the first time.
So, scroll back up to the very top.
Here's the first time that we ran the command.
You'll notice it up here it said,
"Unable to find image locally."
But now the second time,
we did not see that message
and that is because we already downloaded it
to our ImageCache on our personal computer.
So, the big lesson here
is that the first time that you try
to make use of any of these public images over here,
you're gonna have to do a little bit of a download.
But then in the future after that,
you can start up a container
using that image much more quickly
because the image has already been downloaded
to your computer.
All right, now in this entire flow,
one thing that we've been kind of light on at this point
is talking about exactly what a container is.
So, let's take a quick pause right here.
We're gonna come back the next section
and go into a little bit greater detail
on exactly what a container is.
So, quick break and I'll see you in just a minute.