1 00:00:03,110 --> 00:00:03,680 ‫So in this lecture, 2 00:00:03,680 --> 00:00:09,200 ‫let's have a quick discussion about what actually happens in the background when we run the docker 3 00:00:09,200 --> 00:00:10,670 ‫container run command. 4 00:00:10,970 --> 00:00:15,350 ‫There is a misconception sometimes that Docker is really just running containers and that's its 5 00:00:15,350 --> 00:00:16,240 ‫main job. 6 00:00:16,490 --> 00:00:21,740 ‫But there's actually so much that's happening in the background that it does in addition to those containers 7 00:00:22,130 --> 00:00:23,650 ‫executing commands. 8 00:00:23,660 --> 00:00:28,970 ‫When we type docker container run, in the background it's actually going to look for the image that 9 00:00:28,970 --> 00:00:30,960 ‫we specified at the end of that command. 10 00:00:31,010 --> 00:00:36,170 ‫You remember when we typed nginx at the very end, that was the name of the image we wanted to run 11 00:00:36,530 --> 00:00:37,780 ‫as a new container. 12 00:00:37,820 --> 00:00:43,430 ‫So it's going to look for that locally in the image cache. If it doesn't find it there, it's going to hop 13 00:00:43,430 --> 00:00:48,420 ‫over to Docker Hub, which is its default remote image repository. 14 00:00:49,360 --> 00:00:53,670 ‫By default, it'll look it up there and download it and store it in the image cache. 15 00:00:53,680 --> 00:00:58,790 ‫So, if we didn't specify a version -- and we didn't, we just typed in nginx -- 16 00:00:58,930 --> 00:01:05,500 ‫you can actually type in nginx colon some version -- and we'll get into that in next section -- but without 17 00:01:05,500 --> 00:01:08,170 ‫specifying a version, it'll just choose the latest. 18 00:01:08,170 --> 00:01:13,950 ‫Then, once it's got that image and ready to go, it's going to start up a new container based on that image. 19 00:01:14,110 --> 00:01:15,630 ‫It's not going to make a copy of the image. 20 00:01:15,640 --> 00:01:22,660 ‫It's actually going to just start a new layer of changes, right on top of where that image left off, and 21 00:01:22,780 --> 00:01:25,300 ‫it's going to customize the networking. 22 00:01:25,300 --> 00:01:32,860 ‫It's going to give it a specific virtual IP address that's inside a Docker virtual network. It's 23 00:01:32,860 --> 00:01:37,960 ‫actually going to open up the port that we specified. If we didn't specify the Publish command, the 24 00:01:37,960 --> 00:01:41,620 ‫--publish, it's not going to open up any ports at all. 25 00:01:41,710 --> 00:01:48,580 ‫Since we did the 80:80, that's telling it to take the port 80 on the host and forward all that 26 00:01:48,580 --> 00:01:56,260 ‫traffic to the port 80 in the container. Then that container finally will actually start using a 27 00:01:56,260 --> 00:02:01,840 ‫command specified in the Dockerfile, which will also talk about the next section. 28 00:02:02,040 --> 00:02:05,920 ‫You can actually change a majority of these commands from the command line. 29 00:02:06,060 --> 00:02:07,680 ‫These are all really defaults. 30 00:02:07,680 --> 00:02:11,110 ‫We can actually specify the version of our image. 31 00:02:11,310 --> 00:02:17,160 ‫We can specify different ports or the default command to run when it starts that container. 32 00:02:17,400 --> 00:02:21,940 ‫But since we had a very simple command, it just used a lot of defaults coming out of the box. 33 00:02:21,960 --> 00:02:25,400 ‫As you can see, definitely a lot going on the background. 34 00:02:25,440 --> 00:02:29,130 ‫And later on, we're going to dive into each one of these in separate sections.