In last section we downloaded and installed Docker for Windows or Docker from Mac on your personal computer.
You should now used to run 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
CLIA.
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 dash world yes it is kind of a Hello World
thing of sorts.
Don't worry it's gonna be rather interesting.
All then press enter and we're gonna very quickly see a lot of text start to scroll along the screen.
Now I got to 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 lists 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 going to 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 then mind let's go take a look at a couple of diagrams that are gonna help explain what just occurred
when we ran 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 CLIA.
Again the docker Seelye 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 is to 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 image cache.
Now because you and I just installed Docker on our personal computers that image cache is currently
empty.
We have no images that have already been downloaded before.
So because the image cache 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 that 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 image
cache where it can now be reran at some point the future very quickly without having to read download
it from the Docker Hub.
So essentially we downloaded it over here like so.
After that the docker server then said OK great I've got this image and now it's time to use it to create
an instance of a container and remember what we've 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 that up here it said unable to find a match locally.
But now the second time we did not see that message.
And that is because we already download it to our image cache 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 going to 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 going to 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.