1 00:00:00,000 --> 00:00:04,200 [Intro Music] 2 00:00:04,259 --> 00:00:06,119 Now you know that every image is 3 00:00:06,119 --> 00:00:08,939 read-only, and it has multiple FS 4 00:00:08,939 --> 00:00:11,459 layers. Now's a good time to create 5 00:00:11,459 --> 00:00:13,589 a new container based on already 6 00:00:13,589 --> 00:00:15,959 pulled image. And let's create 7 00:00:15,959 --> 00:00:18,479 first hello-world container. For 8 00:00:18,479 --> 00:00:20,879 that, let's use 'docker run' command, 9 00:00:20,909 --> 00:00:22,859 that will create a new container; 10 00:00:23,069 --> 00:00:25,289 and afterwards, as argument we 11 00:00:25,289 --> 00:00:27,479 supply the name of the image we 12 00:00:27,509 --> 00:00:29,819 want to use, 'hello-world'. 13 00:00:30,209 --> 00:00:32,339 Recap that this image is already 14 00:00:32,339 --> 00:00:34,349 located in our local cache, we have 15 00:00:34,379 --> 00:00:36,119 already pulled it from Docker Hub. 16 00:00:36,389 --> 00:00:39,449 Great. Let's press Enter. And you 17 00:00:39,449 --> 00:00:41,939 simply see some text in this 18 00:00:41,969 --> 00:00:44,729 output. And afterwards, we go back 19 00:00:44,759 --> 00:00:47,819 to terminal. And that means that 20 00:00:47,819 --> 00:00:51,059 container is no longer running. It 21 00:00:51,059 --> 00:00:53,129 has performed some job and that's 22 00:00:53,129 --> 00:00:55,319 it. And now there are two 23 00:00:55,319 --> 00:00:57,749 questions. First one, why this 24 00:00:57,749 --> 00:00:59,909 container has printed this text to 25 00:00:59,909 --> 00:01:02,369 the terminal? How it knows which 26 00:01:02,399 --> 00:01:04,589 action to perform when we create 27 00:01:04,589 --> 00:01:07,259 new container? And second question, 28 00:01:07,379 --> 00:01:10,409 why this container has exited? Why 29 00:01:10,409 --> 00:01:12,539 it is no longer running? Actually, 30 00:01:12,539 --> 00:01:14,159 I could verify that it is not running 31 00:01:14,159 --> 00:01:16,439 anymore using 'docker ps' command, 32 00:01:16,469 --> 00:01:18,869 and list of active containers is 33 00:01:18,869 --> 00:01:21,389 empty. Before answering those 34 00:01:21,389 --> 00:01:23,699 questions, let me read together 35 00:01:23,699 --> 00:01:26,189 with you this output, 'Hello from 36 00:01:26,189 --> 00:01:27,959 Docker! This message shows that 37 00:01:27,959 --> 00:01:29,339 your installation appears to be 38 00:01:29,339 --> 00:01:31,649 working correctly. To generate this 39 00:01:31,649 --> 00:01:33,629 message Docker took following 40 00:01:33,629 --> 00:01:36,809 steps. First sep, Docker client 41 00:01:36,929 --> 00:01:39,809 contacted the Docker daemon'. Recap 42 00:01:39,809 --> 00:01:42,029 that 'docker' command is actually a 43 00:01:42,059 --> 00:01:44,489 Docker Client. It is a binary file 44 00:01:44,519 --> 00:01:46,829 located at your computer. And when 45 00:01:46,829 --> 00:01:48,959 you enter 'docker', along with any 46 00:01:48,959 --> 00:01:51,239 additional commands, Docker Client 47 00:01:51,539 --> 00:01:54,629 contacts Docker Daemon, and sends 48 00:01:54,659 --> 00:01:56,579 this command to it. That's what 49 00:01:56,579 --> 00:01:59,519 happened under the hood. Next step, 50 00:01:59,819 --> 00:02:02,039 'Docker daemon pulled hello-world 51 00:02:02,099 --> 00:02:04,889 image from Docker Hub'. Basically, 52 00:02:04,919 --> 00:02:07,079 we have already pulled this image, 53 00:02:07,289 --> 00:02:09,239 that's why this step was skipped. 54 00:02:09,719 --> 00:02:11,309 Docker has verified that there was 55 00:02:11,309 --> 00:02:13,318 already a hello-world image located 56 00:02:13,348 --> 00:02:15,239 in local cache, that's why there is 57 00:02:15,269 --> 00:02:17,039 no need to pull it from Docker Hub. 58 00:02:17,789 --> 00:02:20,369 Next step, 'Docker daemon created a 59 00:02:20,369 --> 00:02:22,769 new container from that image which 60 00:02:22,769 --> 00:02:24,899 runs executable that produces 61 00:02:24,929 --> 00:02:26,609 output you are currently reading'. 62 00:02:27,629 --> 00:02:30,239 That means that Docker has created 63 00:02:30,239 --> 00:02:32,729 a new container based on hello- 64 00:02:32,759 --> 00:02:36,029 world image, but what is actually 65 00:02:36,029 --> 00:02:38,279 container? I'll answer this 66 00:02:38,279 --> 00:02:39,989 question in the next lecture. But 67 00:02:39,989 --> 00:02:41,489 let me finish reading this output. 68 00:02:42,239 --> 00:02:44,459 Finally, 'Docker daemon streamed that 69 00:02:44,489 --> 00:02:46,469 output to the Docker client, which 70 00:02:46,469 --> 00:02:49,499 sent it to your terminal'. It means 71 00:02:49,499 --> 00:02:51,119 that communication between Docker 72 00:02:51,119 --> 00:02:53,639 Client and Docker Daemon is bi- 73 00:02:53,639 --> 00:02:56,429 directional. Docker Client sends 74 00:02:56,459 --> 00:02:58,559 some commands to Docker Daemon, and 75 00:02:58,589 --> 00:03:00,839 Docker Daemon returns some result, 76 00:03:01,229 --> 00:03:02,789 and this result was returned 77 00:03:02,789 --> 00:03:04,829 actually by Docker Daemon, and 78 00:03:04,829 --> 00:03:07,109 Docker Client has printed this text 79 00:03:07,139 --> 00:03:09,689 to the terminal. And afterwards 80 00:03:09,719 --> 00:03:12,029 last step that was omitted here, 81 00:03:12,299 --> 00:03:15,089 this Docker container was stopped, 82 00:03:15,989 --> 00:03:17,399 because it has already done 83 00:03:17,429 --> 00:03:20,309 its job. Now, let me proceed, and 84 00:03:20,309 --> 00:03:22,799 next let me clarify a bit deeper 85 00:03:22,859 --> 00:03:24,329 what actually happened under the 86 00:03:24,329 --> 00:03:27,359 hood, and what is container, and why 87 00:03:27,359 --> 00:03:29,909 container decides to print such 88 00:03:29,909 --> 00:03:32,009 text to the terminal. Let me talk 89 00:03:32,009 --> 00:03:33,763 about it in the next lecture. Bye-Bye. 90 00:03:33,763 --> 00:03:36,106 [no audio]