1 00:00:00,000 --> 00:00:04,200 [Intro Music] 2 00:00:04,230 --> 00:00:05,880 In each new programming language 3 00:00:05,880 --> 00:00:07,920 learner will always start with 4 00:00:07,920 --> 00:00:09,960 simple program called hello-world. 5 00:00:10,440 --> 00:00:12,330 And the studying of Docker is not 6 00:00:12,330 --> 00:00:14,580 an exception. That's why I suggest 7 00:00:14,610 --> 00:00:17,100 to start from the very first simple 8 00:00:17,100 --> 00:00:18,750 container, the most simple one, 9 00:00:19,110 --> 00:00:21,570 called hello-world. For now, you 10 00:00:21,570 --> 00:00:22,770 should have Docker installed on 11 00:00:22,770 --> 00:00:24,330 your computer, and we are basically 12 00:00:24,330 --> 00:00:26,760 ready to go. Let's go to terminal, 13 00:00:26,790 --> 00:00:29,850 I'll use macOS in this section, 14 00:00:30,090 --> 00:00:32,220 and the let me simply type 'docker 15 00:00:32,610 --> 00:00:36,990 run hello-world', like this, press 16 00:00:36,990 --> 00:00:40,500 Enter, and see what will happen. I 17 00:00:40,500 --> 00:00:42,420 see message, 'Unable to find image 18 00:00:42,420 --> 00:00:44,520 'hello-world:latest' locally'. 19 00:00:44,820 --> 00:00:46,860 After that image is pulled from 20 00:00:46,860 --> 00:00:49,470 Docker Hub. And afterwards, I see 21 00:00:49,530 --> 00:00:52,950 this section of text in terminal - 22 00:00:53,100 --> 00:00:55,200 Hello from Docker! This message 23 00:00:55,200 --> 00:00:57,180 shows that installation appears to 24 00:00:57,180 --> 00:00:58,770 be working correctly, and so on. 25 00:00:59,430 --> 00:01:02,160 Afterwards, I got back to terminal 26 00:01:02,160 --> 00:01:04,800 and actually you see that container 27 00:01:04,800 --> 00:01:07,560 was exited. You could also verify 28 00:01:07,560 --> 00:01:10,020 that there are no currently running 29 00:01:10,020 --> 00:01:13,020 containers using command 'docker ps'. 30 00:01:13,290 --> 00:01:15,720 And you see here empty output only 31 00:01:15,720 --> 00:01:17,730 with headers of the columns like 32 00:01:17,760 --> 00:01:20,160 CONTAINER ID, IMAGE, COMMAND, and so 33 00:01:20,160 --> 00:01:23,790 on. Let's try to run the same 34 00:01:23,850 --> 00:01:26,970 container once again. 'docker run 35 00:01:27,000 --> 00:01:30,210 hello-world', Enter, and now 36 00:01:30,210 --> 00:01:31,950 you'll see the same result as 37 00:01:31,950 --> 00:01:34,290 before. The goal of this container 38 00:01:34,320 --> 00:01:37,980 is simply to start and print this 39 00:01:38,010 --> 00:01:41,040 piece of text to terminal. Nothing 40 00:01:41,040 --> 00:01:43,920 else. As soon as this is done, 41 00:01:43,980 --> 00:01:47,850 container exits. That's all about 42 00:01:47,850 --> 00:01:49,500 the most simple hello-world 43 00:01:49,500 --> 00:01:52,290 container that you could use in 44 00:01:52,320 --> 00:01:54,780 Docker. And also from this example, 45 00:01:54,780 --> 00:01:57,540 you see that Docker has actually 46 00:01:57,750 --> 00:02:00,630 pulled the image called hello-world 47 00:02:00,660 --> 00:02:03,630 :latest' from Docker Hub. You 48 00:02:03,630 --> 00:02:06,810 see this action here. This image 49 00:02:06,840 --> 00:02:11,070 also has sha256 Hash. And here you 50 00:02:11,070 --> 00:02:14,310 see this hash as well. Great. 51 00:02:14,580 --> 00:02:16,860 That's how you're able to create 52 00:02:16,890 --> 00:02:18,840 the very first container pretty 53 00:02:18,840 --> 00:02:21,090 fast and easily. But basically this 54 00:02:21,090 --> 00:02:23,220 container is useless. All what it 55 00:02:23,220 --> 00:02:25,020 does, it simply prints to the 56 00:02:25,020 --> 00:02:26,670 console a piece of text, and that's 57 00:02:26,670 --> 00:02:29,130 it. Also, let's have a look at the 58 00:02:29,130 --> 00:02:31,200 this sequence of actions that 59 00:02:31,230 --> 00:02:32,820 actually happened under the hood 60 00:02:33,000 --> 00:02:35,160 when we have entered this command 61 00:02:35,190 --> 00:02:38,250 'docker run hello-world'. First step, 62 00:02:38,310 --> 00:02:40,590 Docker client contacted the Docker 63 00:02:40,590 --> 00:02:42,660 daemon. It means that there are two 64 00:02:42,660 --> 00:02:44,550 different pieces of software - 65 00:02:44,790 --> 00:02:46,860 Docker client on one side, and 66 00:02:46,890 --> 00:02:49,560 Docker daemon or Docker server on 67 00:02:49,560 --> 00:02:52,500 the other side. Next, Docker daemon 68 00:02:52,500 --> 00:02:54,240 pulled the "hello-world" image from 69 00:02:54,240 --> 00:02:55,800 the Docker Hub. That's what I have 70 00:02:55,800 --> 00:02:58,170 already told you. We have tried to 71 00:02:58,170 --> 00:03:00,360 find the image called 'hello-world 72 00:03:00,360 --> 00:03:03,270 :latest' locally, but there 73 00:03:03,270 --> 00:03:05,430 were no images, there was just 74 00:03:05,430 --> 00:03:06,960 clean installation and that's it. 75 00:03:07,350 --> 00:03:09,420 That's why Docker server or Docker 76 00:03:09,420 --> 00:03:12,030 daemon has decided to pull image 77 00:03:12,030 --> 00:03:14,490 'hello-world' from a Remote Registry 78 00:03:14,520 --> 00:03:16,710 called Docker Hub. Here you see 79 00:03:16,740 --> 00:03:19,110 this information. On the next step, 80 00:03:19,140 --> 00:03:21,330 step number 3, Docker daemon 81 00:03:21,330 --> 00:03:23,670 created a new container from that 82 00:03:23,700 --> 00:03:25,950 image which runs executable that 83 00:03:25,950 --> 00:03:27,540 produces output you are currently 84 00:03:27,540 --> 00:03:30,270 reading. It means that after pulling 85 00:03:30,270 --> 00:03:32,790 the image from Remote Registry, from 86 00:03:32,790 --> 00:03:35,940 Docker Hub, local Docker has 87 00:03:35,940 --> 00:03:38,280 created a new container based on 88 00:03:38,280 --> 00:03:41,280 that image. On the last step, 89 00:03:41,310 --> 00:03:43,920 Docker daemon streamed that output 90 00:03:43,920 --> 00:03:46,170 to the Docker client. And that's why 91 00:03:46,200 --> 00:03:48,630 you actually see this text here in 92 00:03:48,630 --> 00:03:51,300 your terminal. And afterwards, the 93 00:03:51,330 --> 00:03:52,920 Docker container was basically 94 00:03:52,920 --> 00:03:55,110 terminated. Actually, I would add 95 00:03:55,170 --> 00:03:57,000 here additional step, step number 96 00:03:57,000 --> 00:04:00,900 5, container was exited. That's 97 00:04:00,930 --> 00:04:02,490 actually all what happened under 98 00:04:02,490 --> 00:04:04,050 the hood when you have entered 99 00:04:04,110 --> 00:04:06,150 this command 'docker run hello- 100 00:04:06,150 --> 00:04:08,160 world'. When you run the same 101 00:04:08,160 --> 00:04:10,350 command, second time, third time 102 00:04:10,350 --> 00:04:13,590 and so on, Docker skips this step, 103 00:04:13,830 --> 00:04:16,110 because this image 'hello-world' is 104 00:04:16,140 --> 00:04:18,510 already present in your local 105 00:04:18,540 --> 00:04:20,610 cache, and you could verify that 106 00:04:20,610 --> 00:04:23,790 using command 'docker images', and 107 00:04:23,790 --> 00:04:25,709 you'll see first image here on 108 00:04:25,709 --> 00:04:27,930 the list, 'hello-world', and there was 109 00:04:27,930 --> 00:04:29,580 a tag called 'latest'. We will get 110 00:04:29,580 --> 00:04:30,990 back to tags a bit later in this 111 00:04:30,990 --> 00:04:33,000 course. Also, you may see here 112 00:04:33,060 --> 00:04:35,820 IMAGE ID. It is simply a set of 113 00:04:35,820 --> 00:04:37,860 characters, hexadecimal characters, 114 00:04:37,860 --> 00:04:40,410 basically. And you'll see how long 115 00:04:40,410 --> 00:04:42,750 ago this image was created. It was 116 00:04:42,750 --> 00:04:45,330 created more than one year ago, and 117 00:04:45,330 --> 00:04:47,910 its size is simply two kilobytes. 118 00:04:48,120 --> 00:04:50,040 It is the most smallest image 119 00:04:50,040 --> 00:04:52,920 possible. Okay, that's all for this 120 00:04:52,920 --> 00:04:55,282 example, and let's move on to next one. 121 00:04:55,282 --> 00:04:56,600 [no audio]