WEBVTT

00:00.750 --> 00:01.583
-: In the last section,

00:01.583 --> 00:03.900
we downloaded and installed Docker for Windows

00:03.900 --> 00:06.600
or Docker for Mac on your personal computer.

00:06.600 --> 00:08.880
You should now be able to ran the command Docker version

00:08.880 --> 00:09.720
at the command line

00:09.720 --> 00:12.060
and see a little bit of text like this appear.

00:12.060 --> 00:13.500
I now want to write out

00:13.500 --> 00:15.660
our very first kind of meaningful command

00:15.660 --> 00:18.540
with the Docker client or the Docker CLI.

00:18.540 --> 00:20.250
We're going to run a very quick command here,

00:20.250 --> 00:21.083
and then we're gonna go

00:21.083 --> 00:23.670
through a very specific flow of actions that occurred

00:23.670 --> 00:25.500
when that command got executed.

00:25.500 --> 00:26.940
So, here's the command.

00:26.940 --> 00:30.930
We're gonna write docker run hello-world.

00:30.930 --> 00:33.330
Yes, it is kind of a hello world thing of sorts.

00:33.330 --> 00:35.550
Don't worry, it's gonna be rather interesting.

00:35.550 --> 00:37.320
I'll then press enter,

00:37.320 --> 00:38.550
and we're gonna very quickly see

00:38.550 --> 00:41.520
a lot of text start to scroll along the screen.

00:41.520 --> 00:43.230
Now, I'm gonna scroll up a little bit

00:43.230 --> 00:44.063
and you'll see

00:44.063 --> 00:46.530
a little hello from Docker message right here.

00:46.530 --> 00:48.060
And then you'll notice underneath that

00:48.060 --> 00:50.760
it list out these series of steps that just occurred

00:50.760 --> 00:52.170
when you ran that command.

00:52.170 --> 00:54.420
Now, we're going to go over the series of steps right here

00:54.420 --> 00:55.260
in great detail.

00:55.260 --> 00:56.093
So, if you want to,

00:56.093 --> 00:58.440
you can kind of ignore that text for right now.

00:58.440 --> 01:00.240
I'm gonna scroll up a little bit further

01:00.240 --> 01:01.927
and I want you to see up here it says,

01:01.927 --> 01:05.040
"Unable to find image hello world locally."

01:05.040 --> 01:06.120
All right, so with that mind,

01:06.120 --> 01:07.800
let's go take a look at a couple of diagrams

01:07.800 --> 01:09.750
that are gonna help explain what just occurred

01:09.750 --> 01:11.000
when we run that command.

01:12.810 --> 01:14.190
All right, here we go.

01:14.190 --> 01:15.030
So, at the Terminal,

01:15.030 --> 01:18.900
you and I executed the command, docker run hello-world.

01:18.900 --> 01:22.650
That starts up that Docker client or the Docker CLI.

01:22.650 --> 01:23.880
Again, the Docker CLI

01:23.880 --> 01:26.460
is in charge of taking commands from you,

01:26.460 --> 01:28.650
kind of doing a little bit of processing on them,

01:28.650 --> 01:30.360
and then communicating the commands

01:30.360 --> 01:32.730
over to something called the Docker server.

01:32.730 --> 01:35.250
And it's that docker server that is really in charge

01:35.250 --> 01:37.020
of the heavy lifting.

01:37.020 --> 01:39.330
When we ran the command, docker run hello-world,

01:39.330 --> 01:42.690
that meant that we wanted to start up a new container

01:42.690 --> 01:46.050
using the image with the name of hello world.

01:46.050 --> 01:47.280
The hello world image

01:47.280 --> 01:50.010
has a tiny little program inside of it

01:50.010 --> 01:51.960
whose sole purpose, sole job,

01:51.960 --> 01:54.390
issue print-out the message that you see right here.

01:54.390 --> 01:56.703
That's the only purpose of that image.

01:57.630 --> 01:58.860
Now, when we ran that command

01:58.860 --> 02:01.170
and it was issued over to the Docker server,

02:01.170 --> 02:05.100
a series of actions very quickly occurred in the background.

02:05.100 --> 02:06.000
The Docker server

02:06.000 --> 02:08.850
saw that we were trying to start up a new container

02:08.850 --> 02:11.430
using an image called hello world.

02:11.430 --> 02:13.290
The first thing that the Docker server did

02:13.290 --> 02:16.590
was check to see if it already had a local copy.

02:16.590 --> 02:18.771
Like a copy on your personal machine

02:18.771 --> 02:22.710
of the hello world image or that hello world file.

02:22.710 --> 02:23.880
So, the Docker server

02:23.880 --> 02:26.340
looked into something called the ImageCash.

02:26.340 --> 02:28.950
Now, because you and I just installed Docker

02:28.950 --> 02:30.365
on our personal computers,

02:30.365 --> 02:32.370
the ImageCache is currently empty.

02:32.370 --> 02:36.120
We have no images that have already been downloaded before.

02:36.120 --> 02:37.950
So, because the ImageCache was empty,

02:37.950 --> 02:39.750
the Docker server decided to reach out

02:39.750 --> 02:42.930
to a free service called Docker Hub.

02:42.930 --> 02:46.440
The Docker Hub is a repository of free public images

02:46.440 --> 02:48.150
so you can freely download and run

02:48.150 --> 02:49.890
on your personal computer.

02:49.890 --> 02:52.567
So, Docker server reached out to Docker Hub and said,

02:52.567 --> 02:55.800
"Hey, I'm looking for an image called hello world.

02:55.800 --> 02:56.817
Do you have one?"

02:57.720 --> 02:59.790
Of course, the Docker hub does.

02:59.790 --> 03:03.540
So, Docker server downloaded this hello world file

03:03.540 --> 03:07.680
and stored it on your personal computer in this ImageCache

03:07.680 --> 03:09.000
where it can now be reran

03:09.000 --> 03:11.010
at some point in the future very quickly

03:11.010 --> 03:13.950
without having to re-download it from the Docker Hub.

03:13.950 --> 03:16.953
So, essentially, we downloaded it over here like some.

03:17.880 --> 03:19.867
After that, the Docker server then said,

03:19.867 --> 03:21.630
"Okay, great. I've got this image

03:21.630 --> 03:23.100
and now, it's time to use it

03:23.100 --> 03:25.890
to create an instance of a container."

03:25.890 --> 03:26.723
And I remember

03:26.723 --> 03:28.920
what we just said about a container a moment ago.

03:28.920 --> 03:31.980
An instant container is an instance of an image.

03:31.980 --> 03:35.643
Its sole purpose is to run one very specific program.

03:37.380 --> 03:38.550
So, the Docker server

03:38.550 --> 03:40.590
then essentially took that single file,

03:40.590 --> 03:42.030
loaded it up into memory,

03:42.030 --> 03:43.350
created a container out of it,

03:43.350 --> 03:45.930
and then ran a single program inside of it.

03:45.930 --> 03:47.700
And that single program's purpose

03:47.700 --> 03:50.730
was to print out the message that you see right here.

03:50.730 --> 03:51.720
So, that's pretty much it.

03:51.720 --> 03:54.780
That's what happens when you run this Docker run command.

03:54.780 --> 03:56.310
It reaches out to Docker Hub,

03:56.310 --> 03:57.360
it grabs the image,

03:57.360 --> 04:00.090
and then it creates a container out of that image.

04:00.090 --> 04:02.340
Now, one thing that you'll notice that's kind of interesting

04:02.340 --> 04:06.508
if we run the docker run hello-world command a second time,

04:06.508 --> 04:09.510
you'll notice that we are not going to see the message

04:09.510 --> 04:12.870
of downloading or container image not found locally

04:12.870 --> 04:14.280
that we saw the first time.

04:14.280 --> 04:16.770
So, scroll back up to the very top.

04:16.770 --> 04:18.660
Here's the first time that we ran the command.

04:18.660 --> 04:19.897
You'll notice it up here it said,

04:19.897 --> 04:21.690
"Unable to find image locally."

04:21.690 --> 04:23.010
But now the second time,

04:23.010 --> 04:24.810
we did not see that message

04:24.810 --> 04:26.940
and that is because we already downloaded it

04:26.940 --> 04:29.640
to our ImageCache on our personal computer.

04:29.640 --> 04:30.750
So, the big lesson here

04:30.750 --> 04:32.250
is that the first time that you try

04:32.250 --> 04:35.160
to make use of any of these public images over here,

04:35.160 --> 04:37.080
you're gonna have to do a little bit of a download.

04:37.080 --> 04:38.880
But then in the future after that,

04:38.880 --> 04:40.410
you can start up a container

04:40.410 --> 04:42.210
using that image much more quickly

04:42.210 --> 04:43.980
because the image has already been downloaded

04:43.980 --> 04:45.630
to your computer.

04:45.630 --> 04:48.210
All right, now in this entire flow,

04:48.210 --> 04:50.640
one thing that we've been kind of light on at this point

04:50.640 --> 04:53.880
is talking about exactly what a container is.

04:53.880 --> 04:55.710
So, let's take a quick pause right here.

04:55.710 --> 04:57.120
We're gonna come back the next section

04:57.120 --> 04:58.830
and go into a little bit greater detail

04:58.830 --> 05:00.690
on exactly what a container is.

05:00.690 --> 05:03.173
So, quick break and I'll see you in just a minute.
