1 00:00:00,000 --> 00:00:04,000 [Intro Music] 2 00:00:04,080 --> 00:00:06,240 Alright guys, I have just explained 3 00:00:06,240 --> 00:00:08,220 you how to use the '-t' option 4 00:00:08,340 --> 00:00:10,170 along with container run command. 5 00:00:10,440 --> 00:00:11,790 And now you know difference between 6 00:00:11,790 --> 00:00:14,010 '-i', '-t' and '-it' options. 7 00:00:14,040 --> 00:00:15,090 And we have actually tried the 8 00:00:15,090 --> 00:00:17,400 different variants with 'docker run' 9 00:00:17,400 --> 00:00:20,070 command. Now it's time to start the 10 00:00:20,070 --> 00:00:21,900 creation of multiple containers 11 00:00:21,930 --> 00:00:24,630 using the same image. And in this 12 00:00:24,630 --> 00:00:26,280 lecture I'll create two 13 00:00:26,280 --> 00:00:28,530 containers using ubuntu image, and 14 00:00:28,530 --> 00:00:29,790 I'll demonstrate that those 15 00:00:29,790 --> 00:00:31,410 containers are completely two 16 00:00:31,440 --> 00:00:33,060 different containers, and they are 17 00:00:33,060 --> 00:00:35,490 fully independent, except the fact 18 00:00:35,490 --> 00:00:37,440 that they basically share resources 19 00:00:37,470 --> 00:00:39,600 of Docker host, I mean the CPU 20 00:00:39,600 --> 00:00:42,720 resources, RAM, and disk. Great. 21 00:00:42,840 --> 00:00:44,610 Let's get our hands dirty, and 22 00:00:44,640 --> 00:00:46,560 let's create first container based 23 00:00:46,590 --> 00:00:50,760 on ubuntu image. 'docker run -it', 24 00:00:50,790 --> 00:00:52,590 I used those two options here, 25 00:00:52,830 --> 00:00:55,290 'ubuntu', because I want to log in 26 00:00:55,320 --> 00:00:57,120 into that container, basically into 27 00:00:57,120 --> 00:01:00,240 the default process called 'bash'. Let's 28 00:01:00,240 --> 00:01:03,180 press Enter, and now I'm inside of 29 00:01:03,180 --> 00:01:04,800 the container. That is the first 30 00:01:04,800 --> 00:01:06,120 container that we have just 31 00:01:06,120 --> 00:01:07,980 created. Let's for example, list 32 00:01:07,980 --> 00:01:11,040 files here. And let's, for testing 33 00:01:11,040 --> 00:01:13,290 purposes, create a new folder here 34 00:01:13,290 --> 00:01:17,370 called 'test'; 'mkdir test'. Let's 'cd' 35 00:01:17,370 --> 00:01:19,350 to this 'test' folder; and let's 36 00:01:19,380 --> 00:01:23,241 create here file 'touch test.txt'. 37 00:01:23,241 --> 00:01:25,890 And let's go back out of this 38 00:01:25,890 --> 00:01:28,080 'test' folder. And if I list files 39 00:01:28,080 --> 00:01:29,970 and folders here, you'll see this 40 00:01:30,000 --> 00:01:31,950 'test' folder here on the list. 41 00:01:32,310 --> 00:01:34,650 Wonderful. Let me now create one 42 00:01:34,650 --> 00:01:36,720 more container based on the same 43 00:01:36,750 --> 00:01:39,060 image, ubuntu. Let me open up a new 44 00:01:39,060 --> 00:01:41,820 tab. Basically, let me drag this 45 00:01:41,820 --> 00:01:45,540 tab here and put those two tabs 46 00:01:45,540 --> 00:01:48,810 side by side, like so because I 47 00:01:48,810 --> 00:01:51,180 want you to see differences between 48 00:01:51,210 --> 00:01:54,390 those two containers. Okay, here is 49 00:01:54,390 --> 00:01:56,010 the first container with ubuntu 50 00:01:56,010 --> 00:01:57,660 image; and here in this container, 51 00:01:57,660 --> 00:01:59,790 we have created a new folder called 52 00:01:59,790 --> 00:02:01,320 'test'; and inside of that folder 53 00:02:01,470 --> 00:02:04,050 there was file called 'test.txt'; 54 00:02:04,320 --> 00:02:05,760 and here in this window, let me 55 00:02:05,760 --> 00:02:08,160 start one more container based on 56 00:02:08,160 --> 00:02:10,470 the same image ubuntu. Same command, 57 00:02:10,500 --> 00:02:13,169 'docker run -it ubuntu'. 58 00:02:14,670 --> 00:02:16,320 Container was started. And notice 59 00:02:16,320 --> 00:02:18,120 that there was difference in 60 00:02:18,120 --> 00:02:21,060 container IDs. Here was actually ID 61 00:02:21,060 --> 00:02:22,440 of this container; and it is 62 00:02:22,470 --> 00:02:24,630 automatically taken as the host 63 00:02:24,630 --> 00:02:26,490 name of this container, of this 64 00:02:26,520 --> 00:02:29,130 computer actually; and here is 65 00:02:29,190 --> 00:02:31,650 this ID that was used for this 66 00:02:31,650 --> 00:02:34,230 container number one. Great. Let's 67 00:02:34,230 --> 00:02:36,360 now list files and folders inside 68 00:02:36,360 --> 00:02:39,540 of this container, 'ls'; and you'll 69 00:02:39,540 --> 00:02:42,480 see same set of folders and files 70 00:02:42,540 --> 00:02:44,040 that we have seen here in this 71 00:02:44,040 --> 00:02:46,020 container before creation of the 72 00:02:46,020 --> 00:02:48,690 'test' folder; and there was no 'test' 73 00:02:48,690 --> 00:02:50,520 folder inside of this container. 74 00:02:51,570 --> 00:02:54,450 This shows you that every container 75 00:02:54,540 --> 00:02:57,570 has its own separated file system. 76 00:02:57,900 --> 00:02:59,580 And file systems of different 77 00:02:59,580 --> 00:03:02,070 containers don't overlap. They are 78 00:03:02,070 --> 00:03:04,080 completely independent. But of 79 00:03:04,080 --> 00:03:05,700 course, those file systems are 80 00:03:05,700 --> 00:03:08,280 stored on the same Docker host. In 81 00:03:08,280 --> 00:03:10,200 this case, Docker host is virtual 82 00:03:10,200 --> 00:03:12,030 machine inside of which those 83 00:03:12,030 --> 00:03:14,010 containers are run. And this virtual 84 00:03:14,010 --> 00:03:15,690 machine is basically running on 85 00:03:15,690 --> 00:03:17,910 this macOS computer, same picture 86 00:03:17,940 --> 00:03:20,850 for Windows computer. Great. I 87 00:03:20,850 --> 00:03:22,620 could also create the some files 88 00:03:22,620 --> 00:03:23,970 and folders inside of this 89 00:03:23,970 --> 00:03:25,590 container. And let me do that 90 00:03:25,590 --> 00:03:27,180 quickly. For example, I could 91 00:03:27,210 --> 00:03:31,770 create a folder called 'test2', 'cd' 92 00:03:31,770 --> 00:03:34,440 to 'test2'; and here let's create 93 00:03:34,440 --> 00:03:37,740 the file 'test2.txt'. Let's list 94 00:03:37,740 --> 00:03:39,942 files here. You'll see 'test2.txt' 95 00:03:39,942 --> 00:03:41,640 file inside of 'test2' folder, 96 00:03:41,820 --> 00:03:43,860 and if I'll 'cd' out of this folder, 97 00:03:44,010 --> 00:03:46,320 you'll see 'test2' folder here in 98 00:03:46,320 --> 00:03:49,080 the root of this container. And 99 00:03:49,080 --> 00:03:50,760 again, if I repeat the same command 100 00:03:50,760 --> 00:03:52,740 here, in container number one, you 101 00:03:52,740 --> 00:03:54,990 will see that there was still 'test' 102 00:03:54,990 --> 00:03:57,540 folder and no 'test2' folder. 103 00:03:58,050 --> 00:03:59,490 Great. That is the difference 104 00:03:59,490 --> 00:04:01,560 between this container and this 105 00:04:01,560 --> 00:04:03,660 container. And now you see that the 106 00:04:03,660 --> 00:04:05,610 containers are fully independent 107 00:04:05,640 --> 00:04:08,130 and they again only share CPU 108 00:04:08,130 --> 00:04:10,050 resources of the Docker host and 109 00:04:10,050 --> 00:04:12,000 RAM. It means that each of those 110 00:04:12,000 --> 00:04:15,600 containers may take up to 100% 111 00:04:15,600 --> 00:04:17,820 resources of the Docker host. And 112 00:04:17,820 --> 00:04:19,410 of course there is possibility to 113 00:04:19,410 --> 00:04:22,050 limit the maximum size of resources 114 00:04:22,050 --> 00:04:24,060 that each container may utilize. 115 00:04:24,180 --> 00:04:25,620 And we will get back to that later 116 00:04:25,620 --> 00:04:27,510 on in this course. Also, you'll see 117 00:04:27,510 --> 00:04:28,920 that those containers have 118 00:04:28,950 --> 00:04:30,990 different host names. And actually 119 00:04:30,990 --> 00:04:32,850 you could verify hostname by typing 120 00:04:32,850 --> 00:04:35,250 the 'hostname' command like so, and 121 00:04:35,250 --> 00:04:36,540 you'll see a hostname of this 122 00:04:36,540 --> 00:04:38,460 container, and actually this host 123 00:04:38,460 --> 00:04:41,070 name is shown here after login 124 00:04:41,070 --> 00:04:43,410 into the container, and if you would 125 00:04:43,410 --> 00:04:44,880 like to check hostname here on this 126 00:04:44,880 --> 00:04:46,260 container you could use same 127 00:04:46,260 --> 00:04:48,780 command 'hostname', and you'll see 128 00:04:48,840 --> 00:04:51,000 hostname of this container. We 129 00:04:51,000 --> 00:04:53,220 could also verify IP addresses of 130 00:04:53,220 --> 00:04:54,810 every container, and for that you 131 00:04:54,810 --> 00:04:57,300 could use command 'hostname -i', 132 00:04:58,020 --> 00:05:00,210 and 'hostname -i' in this 133 00:05:00,210 --> 00:05:02,160 container, and you'll see that those 134 00:05:02,160 --> 00:05:04,080 containers have different IP 135 00:05:04,080 --> 00:05:05,940 addresses. But they are basically 136 00:05:05,970 --> 00:05:07,740 from the same network. And it is 137 00:05:07,770 --> 00:05:09,780 default bridge network inside 138 00:05:09,780 --> 00:05:12,150 of the Docker host. Great. That's 139 00:05:12,150 --> 00:05:13,950 how those containers differ. And 140 00:05:13,950 --> 00:05:15,840 the goal of this lecture was to 141 00:05:15,840 --> 00:05:17,370 demonstrate to you that containers 142 00:05:17,400 --> 00:05:19,530 are fully independent, and have 143 00:05:19,530 --> 00:05:21,810 different file systems. Let's now 144 00:05:21,810 --> 00:05:23,370 proceed and in the next lecture, 145 00:05:23,550 --> 00:05:26,460 let's develop this topic, and let's 146 00:05:26,460 --> 00:05:28,800 try to create two different nginx 147 00:05:28,800 --> 00:05:31,260 servers that will host different 148 00:05:31,380 --> 00:05:33,330 files from different folders. And 149 00:05:33,330 --> 00:05:34,860 again, that will prove that you are 150 00:05:34,860 --> 00:05:36,750 able to create multiple containers 151 00:05:36,810 --> 00:05:39,000 based on the same image. And one 152 00:05:39,000 --> 00:05:40,350 more thing here that I wanted to 153 00:05:40,350 --> 00:05:42,930 tell you is that in this case, you 154 00:05:42,930 --> 00:05:44,730 were not prompted to download any 155 00:05:44,730 --> 00:05:47,070 new image, something else, image was 156 00:05:47,070 --> 00:05:49,080 already in your local cache, and it 157 00:05:49,080 --> 00:05:50,940 was simply reused for both 158 00:05:50,940 --> 00:05:53,010 containers. That's why you have 159 00:05:53,010 --> 00:05:54,960 created those containers pretty 160 00:05:54,960 --> 00:05:57,510 fast, in a matter of seconds. And of 161 00:05:57,510 --> 00:05:59,010 course, if I will create a new 162 00:05:59,010 --> 00:06:01,530 container, ubuntu container now, it 163 00:06:01,530 --> 00:06:03,480 will get the clean file system 164 00:06:03,630 --> 00:06:05,910 without any 'test' or 'test2' 165 00:06:05,910 --> 00:06:07,710 folders that we have created in 166 00:06:07,710 --> 00:06:09,840 previous containers. Wonderful. 167 00:06:09,960 --> 00:06:11,670 Let's now proceed and next let's 168 00:06:11,670 --> 00:06:13,980 create the two nginx containers 169 00:06:14,010 --> 00:06:16,230 with two different set of files. 170 00:06:16,260 --> 00:06:17,460 See you next. Bye-Bye. 171 00:06:17,460 --> 00:06:19,562 [no audio]