1 00:00:00,720 --> 00:00:06,520 In last section we downloaded and installed Docker for Windows or Docker from Mac on your personal computer. 2 00:00:06,570 --> 00:00:10,680 You should now used to run the command Docker version at the command line and see a little bit of text 3 00:00:10,680 --> 00:00:11,920 like this appear. 4 00:00:12,030 --> 00:00:17,370 I now want to write out our very first kind of meaningful command with the docker client or the docker 5 00:00:17,370 --> 00:00:18,240 CLIA. 6 00:00:18,510 --> 00:00:22,650 We're going to run a very quick command here and then we're gonna go through a very specific flow of 7 00:00:22,650 --> 00:00:25,450 actions that occurred when that command got executed. 8 00:00:25,470 --> 00:00:32,430 So here's the command we're gonna write Docker run Hello dash world yes it is kind of a Hello World 9 00:00:32,430 --> 00:00:33,230 thing of sorts. 10 00:00:33,270 --> 00:00:35,470 Don't worry it's gonna be rather interesting. 11 00:00:35,550 --> 00:00:41,250 All then press enter and we're gonna very quickly see a lot of text start to scroll along the screen. 12 00:00:41,490 --> 00:00:46,650 Now I got to scroll up a little bit and you'll see a little hello from Docker message right here and 13 00:00:46,650 --> 00:00:51,150 then you'll notice underneath that it lists out these series of steps that just occurred when you ran 14 00:00:51,150 --> 00:00:52,140 that command. 15 00:00:52,140 --> 00:00:56,250 Now we're going to go over the series of steps right here in great detail so if you want to you can 16 00:00:56,250 --> 00:00:58,240 kind of ignore that text for right now. 17 00:00:58,440 --> 00:01:01,330 I'm going to scroll up a little bit further and I want you to see up here. 18 00:01:01,350 --> 00:01:05,040 It says unable to find image hello world locally. 19 00:01:05,040 --> 00:01:05,240 All right. 20 00:01:05,250 --> 00:01:09,630 So then mind let's go take a look at a couple of diagrams that are gonna help explain what just occurred 21 00:01:09,690 --> 00:01:13,170 when we ran that command all right. 22 00:01:13,170 --> 00:01:14,160 Here we go. 23 00:01:14,160 --> 00:01:17,610 So at the terminal you and I executed the command Docker run. 24 00:01:17,670 --> 00:01:18,630 Hello world. 25 00:01:18,840 --> 00:01:22,480 That starts up that Docker client or the docker CLIA. 26 00:01:22,620 --> 00:01:28,050 Again the docker Seelye is in charge of taking commands from you kind of doing a little bit of processing 27 00:01:28,050 --> 00:01:32,710 on them and then communicating the commands over to something called the docker server. 28 00:01:32,850 --> 00:01:38,190 And it's that Docker server that is really in charge of the heavy lifting when we ran the command Docker 29 00:01:38,190 --> 00:01:39,280 run hello world. 30 00:01:39,300 --> 00:01:46,110 That meant that we wanted to start up a new container using the image with the name of hello world the 31 00:01:46,110 --> 00:01:52,680 hello world image has a tiny little program inside of it whose sole purpose sole job is to print out 32 00:01:52,680 --> 00:01:54,360 the message that you see right here. 33 00:01:54,360 --> 00:01:57,570 That's the only purpose of that image. 34 00:01:57,570 --> 00:02:03,240 Now when we ran that command and it was issued over to the docker server a series of actions very quickly 35 00:02:03,240 --> 00:02:04,740 occurred in the background. 36 00:02:05,070 --> 00:02:11,330 The Docker server saw that we were trying to start up a new container using an image called Hello World. 37 00:02:11,400 --> 00:02:17,190 The first thing that the docker server did was check to see if it already had a local copy like a copy 38 00:02:17,190 --> 00:02:22,680 on your personal machine of the hello world image or that hello world file. 39 00:02:22,680 --> 00:02:26,230 So the docker server looked into something called the image cache. 40 00:02:26,310 --> 00:02:31,740 Now because you and I just installed Docker on our personal computers that image cache is currently 41 00:02:31,740 --> 00:02:32,310 empty. 42 00:02:32,310 --> 00:02:36,010 We have no images that have already been downloaded before. 43 00:02:36,090 --> 00:02:41,250 So because the image cache was empty the docker server decided to reach out to a free service called 44 00:02:41,340 --> 00:02:42,600 Docker Hub. 45 00:02:42,880 --> 00:02:48,720 The Docker Hub is a repository of free public images that you can freely download and run on your personal 46 00:02:48,720 --> 00:02:49,840 computer. 47 00:02:49,860 --> 00:02:55,720 So Docker server reached out to Docker Hub and said Hey I'm looking for an image called Hello world. 48 00:02:55,740 --> 00:02:57,440 Do you have one. 49 00:02:57,720 --> 00:02:59,550 Of course the Docker Hub does. 50 00:02:59,760 --> 00:03:06,840 So Docker server downloaded this hello world file and stored it on your personal computer in this image 51 00:03:06,870 --> 00:03:12,320 cache where it can now be reran at some point the future very quickly without having to read download 52 00:03:12,320 --> 00:03:13,890 it from the Docker Hub. 53 00:03:13,920 --> 00:03:17,860 So essentially we downloaded it over here like so. 54 00:03:17,880 --> 00:03:23,550 After that the docker server then said OK great I've got this image and now it's time to use it to create 55 00:03:23,580 --> 00:03:29,580 an instance of a container and remember what we've just said about a container a moment ago an instant 56 00:03:29,790 --> 00:03:31,950 container is an instance of an image. 57 00:03:31,980 --> 00:03:39,680 Its sole purpose is to run one very specific program so the docker server then essentially took that 58 00:03:39,680 --> 00:03:45,500 single file loaded it up into memory created a container out of it and then ran a single program inside 59 00:03:45,500 --> 00:03:45,890 of it. 60 00:03:46,040 --> 00:03:50,650 And that single program's purpose was to print out the message that you see right here. 61 00:03:50,690 --> 00:03:51,640 So that's pretty much it. 62 00:03:51,650 --> 00:03:54,770 That's what happens when you run this Docker run command. 63 00:03:54,770 --> 00:04:00,050 It reaches out to Docker Hub it grabs the image and then it creates a container out of that image. 64 00:04:00,050 --> 00:04:02,210 Now one thing that you'll notice that's kind of interesting. 65 00:04:02,330 --> 00:04:04,150 If we run the docker run. 66 00:04:04,160 --> 00:04:06,890 Hello World command a second time. 67 00:04:06,890 --> 00:04:12,830 You'll notice that we are not going to see the message of downloading or container image not found locally 68 00:04:12,830 --> 00:04:13,880 that we saw the first time. 69 00:04:14,240 --> 00:04:16,810 So scroll back up to the very top. 70 00:04:16,800 --> 00:04:18,470 Here's the first time that we ran the command. 71 00:04:18,650 --> 00:04:21,620 You'll notice that up here it said unable to find a match locally. 72 00:04:21,620 --> 00:04:24,700 But now the second time we did not see that message. 73 00:04:24,800 --> 00:04:29,220 And that is because we already download it to our image cache on our personal computer. 74 00:04:29,630 --> 00:04:34,100 So the big lesson here is that the first time that you try to make use of any of these public images 75 00:04:34,100 --> 00:04:37,030 over here you're going to have to do a little bit of a download. 76 00:04:37,040 --> 00:04:42,440 But then in the future after that you can start up a container using that image much more quickly because 77 00:04:42,440 --> 00:04:45,590 the image has already been downloaded to your computer. 78 00:04:45,590 --> 00:04:46,700 All right. 79 00:04:46,850 --> 00:04:48,140 Now in this entire flow. 80 00:04:48,140 --> 00:04:53,840 One thing that we've been kind of light on at this point is talking about exactly what a container is. 81 00:04:53,840 --> 00:04:55,660 So let's take a quick pause right here. 82 00:04:55,670 --> 00:04:59,810 We're going to come back the next section and go into a little bit greater detail on exactly what a 83 00:04:59,810 --> 00:05:00,610 container is. 84 00:05:00,650 --> 00:05:02,450 So quick break and I'll see you in just a minute.