1 00:00:00,000 --> 00:00:04,099 [Intro Music] 2 00:00:04,170 --> 00:00:05,730 Well, let's go on. In the 3 00:00:05,730 --> 00:00:07,590 previous lecture we have created 4 00:00:07,590 --> 00:00:09,990 the container using ubuntu image. 5 00:00:10,230 --> 00:00:12,240 And here you see that its size is 6 00:00:12,270 --> 00:00:15,870 around the 65 megabytes. It is 7 00:00:15,870 --> 00:00:18,330 large in container world. And here 8 00:00:18,330 --> 00:00:19,920 in this lecture I will demonstrate 9 00:00:19,920 --> 00:00:22,110 how to use another image called 10 00:00:22,110 --> 00:00:23,300 busybox. 11 00:00:23,310 --> 00:00:24,720 But before doing that, let me 12 00:00:24,720 --> 00:00:26,760 quickly summarize what we have 13 00:00:26,790 --> 00:00:28,470 learned in the previous lecture. 14 00:00:28,950 --> 00:00:30,840 You have seen that if you simply 15 00:00:30,840 --> 00:00:33,360 create container using 'docker run 16 00:00:33,390 --> 00:00:35,730 ubuntu' command, you will basically 17 00:00:35,730 --> 00:00:37,470 see that container will be created 18 00:00:37,470 --> 00:00:38,700 but it will be exited 19 00:00:38,730 --> 00:00:40,590 automatically. That's because 20 00:00:40,590 --> 00:00:42,450 process inside of that container 21 00:00:42,480 --> 00:00:44,280 will be terminated automatically; 22 00:00:44,430 --> 00:00:45,930 and if there are no processes 23 00:00:45,930 --> 00:00:48,240 running, Docker will terminate such 24 00:00:48,240 --> 00:00:50,340 container. It is a first important 25 00:00:50,700 --> 00:00:53,130 outcome. Secondly, you have seen 26 00:00:53,130 --> 00:00:55,560 that with option '-it', basically 27 00:00:55,560 --> 00:00:56,910 it is a combination of two 28 00:00:56,910 --> 00:00:58,890 different options, '-i' and 29 00:00:58,890 --> 00:01:01,200 '-t', bit later I will explain 30 00:01:01,200 --> 00:01:03,660 you what those options mean, you 31 00:01:03,660 --> 00:01:06,870 were able to get access to bash 32 00:01:06,930 --> 00:01:08,850 shell inside of the Ubuntu 33 00:01:08,850 --> 00:01:11,580 container. And as soon as you are 34 00:01:11,580 --> 00:01:14,040 logged into the container, it will 35 00:01:14,040 --> 00:01:16,350 be still up and running. And we 36 00:01:16,350 --> 00:01:18,330 were able to execute some basic 37 00:01:18,330 --> 00:01:19,920 commands and for example, we have 38 00:01:19,920 --> 00:01:22,200 listed the contents of the 'bin' 39 00:01:22,230 --> 00:01:23,730 folder inside of the 'ubuntu' 40 00:01:23,730 --> 00:01:26,970 container. But as soon as we exited 41 00:01:26,970 --> 00:01:29,640 from bash shell, container was 42 00:01:29,670 --> 00:01:31,080 terminated; and the reason for that 43 00:01:31,110 --> 00:01:33,990 is the same as before, process bash 44 00:01:34,080 --> 00:01:36,420 was terminated, there were no 45 00:01:36,510 --> 00:01:38,460 another processes running, and 46 00:01:38,490 --> 00:01:40,230 Docker has terminated such 47 00:01:40,230 --> 00:01:43,350 container. That's that simple. Also 48 00:01:43,350 --> 00:01:45,450 here in this output, you currently 49 00:01:45,450 --> 00:01:47,310 see that there are two different 50 00:01:47,340 --> 00:01:49,980 images available locally - ubuntu 51 00:01:50,100 --> 00:01:53,430 and hello-world. And if you want to 52 00:01:53,430 --> 00:01:56,550 create any container using already 53 00:01:56,610 --> 00:01:58,440 existing images in your local 54 00:01:58,440 --> 00:02:00,420 cache, then there was no need to 55 00:02:00,420 --> 00:02:02,640 pull those images from Remote 56 00:02:02,970 --> 00:02:05,730 Registry Docker Hub. Great. Let's 57 00:02:05,730 --> 00:02:07,740 now get to our third example where 58 00:02:07,770 --> 00:02:10,800 we will use busybox image, and let's 59 00:02:10,830 --> 00:02:12,660 do the same as we have done with 60 00:02:12,690 --> 00:02:15,120 ubuntu image, and let's simply type 61 00:02:15,450 --> 00:02:19,440 'docker run busybox', Enter, again, 62 00:02:19,470 --> 00:02:21,510 Unable to find image 'busybox' 63 00:02:21,540 --> 00:02:24,450 locally; and now we are pulling such 64 00:02:24,480 --> 00:02:26,400 image from a Remote Registry from 65 00:02:26,400 --> 00:02:30,180 Docker Hub. Pull complete; Digest is 66 00:02:30,180 --> 00:02:33,690 here, and Status: Downloaded newer image 67 00:02:33,720 --> 00:02:36,630 for busybox:latest'. Basically, let 68 00:02:36,630 --> 00:02:38,430 me shortly explain you what the 69 00:02:38,430 --> 00:02:41,280 ':latest' here and here means 70 00:02:42,060 --> 00:02:45,270 each image has specific tag. And 71 00:02:45,300 --> 00:02:47,580 this 'latest' here and here is 72 00:02:47,580 --> 00:02:49,920 actually tag. If you don't 73 00:02:49,920 --> 00:02:52,020 specify a tag for specific image 74 00:02:52,050 --> 00:02:53,730 you want to use, here we have 75 00:02:53,730 --> 00:02:55,680 specified simply name of the image 76 00:02:55,710 --> 00:02:59,220 'busybox', Docker will append that 77 00:02:59,250 --> 00:03:02,250 'latest', 'latest' is usually latest 78 00:03:02,280 --> 00:03:05,280 stable version of each image. But 79 00:03:05,310 --> 00:03:07,170 you are able to use different tags 80 00:03:07,200 --> 00:03:10,080 and usually same image may have 81 00:03:10,080 --> 00:03:12,060 multiple different tags. And we 82 00:03:12,060 --> 00:03:13,830 will look at it a bit later. For 83 00:03:13,830 --> 00:03:15,570 now please understand that this is 84 00:03:15,600 --> 00:03:17,730 simply tag. And if you don't 85 00:03:17,730 --> 00:03:19,770 specify a tag for image you want to 86 00:03:19,770 --> 00:03:22,620 use, then that 'latest' will be added 87 00:03:22,740 --> 00:03:25,650 automatically. Great. We have tried 88 00:03:25,680 --> 00:03:28,590 to run busybox container, and again 89 00:03:28,620 --> 00:03:30,360 we have returned back to our 90 00:03:30,360 --> 00:03:32,580 terminal. And behavior here is the 91 00:03:32,580 --> 00:03:34,920 same as we have observed when we 92 00:03:34,920 --> 00:03:37,860 were running ubuntu image. And if I 93 00:03:37,860 --> 00:03:40,200 will enter 'docker ps' now, you'll 94 00:03:40,200 --> 00:03:42,150 see that there were no containers 95 00:03:42,150 --> 00:03:44,670 currently running. But if I enter 96 00:03:44,670 --> 00:03:47,460 'docker ps -a', you'll see that 97 00:03:47,490 --> 00:03:50,580 there was a busybox container that 98 00:03:50,580 --> 00:03:53,160 was exited, in my case five minutes 99 00:03:53,190 --> 00:03:56,010 ago. And the fourth command that 100 00:03:56,010 --> 00:04:00,840 was executed was 'sh' command. 'sh' 101 00:04:00,870 --> 00:04:03,540 is basically also shell same as 102 00:04:03,540 --> 00:04:05,340 with bash, but you see here that 103 00:04:05,340 --> 00:04:07,650 there was no path to '/bin' 104 00:04:07,650 --> 00:04:09,810 folder. We have simply executed 105 00:04:09,870 --> 00:04:13,470 under the hood 'sh' command. Great. 106 00:04:13,680 --> 00:04:16,230 Let's now try to enter this 107 00:04:16,260 --> 00:04:19,500 container using '-it' option. Let 108 00:04:19,500 --> 00:04:21,149 me clear terminal and run 109 00:04:21,149 --> 00:04:23,760 container like so. 'docker run - 110 00:04:23,760 --> 00:04:27,450 it busybox'. In such case we will not 111 00:04:27,450 --> 00:04:30,000 again pull busybox image from 112 00:04:30,030 --> 00:04:31,290 Remote Registry because it's 113 00:04:31,290 --> 00:04:33,150 already present in our local cache. 114 00:04:33,600 --> 00:04:36,960 OK, enter and we are now inside of 115 00:04:36,960 --> 00:04:40,380 the busybox container. And if I'll 116 00:04:40,380 --> 00:04:42,690 enter 'docker ps' now in another tab, 117 00:04:42,720 --> 00:04:44,850 'docker ps', you will see that there 118 00:04:44,850 --> 00:04:47,670 is busybox container running right 119 00:04:47,670 --> 00:04:51,180 now and it is 'Up 40 seconds'. Okay, 120 00:04:51,300 --> 00:04:53,640 let's now use the 'ls' command and 121 00:04:53,640 --> 00:04:55,500 see whether such command is 122 00:04:55,500 --> 00:04:57,540 available inside of this container. 123 00:04:57,750 --> 00:04:59,970 'ls', and yes, this command is here 124 00:05:00,690 --> 00:05:02,820 But you see much shorter list of 125 00:05:02,820 --> 00:05:05,490 folders than we have seen in ubuntu 126 00:05:05,490 --> 00:05:07,620 container. Let's have a look at 127 00:05:07,620 --> 00:05:09,960 contents of the 'bin' folder 'ls bin', 128 00:05:10,560 --> 00:05:12,780 and you'll see such a list of 129 00:05:12,810 --> 00:05:14,910 executables here inside of the bin 130 00:05:14,910 --> 00:05:17,250 folder. And for example, if you try 131 00:05:17,280 --> 00:05:19,740 to find the 'echo' command, it will 132 00:05:19,740 --> 00:05:21,810 be present here as well. And you 133 00:05:21,810 --> 00:05:24,030 are able to use it of course, 'echo 134 00:05:24,990 --> 00:05:27,180 "Hello from Busybox" 135 00:05:28,350 --> 00:05:29,880 and Enter, and you'll see, "Hello from 136 00:05:29,880 --> 00:05:32,760 Busybox" here in this shell. Also, 137 00:05:32,760 --> 00:05:34,050 let's try one more command, for 138 00:05:34,050 --> 00:05:36,210 example 'uptime'. You see that this 139 00:05:36,210 --> 00:05:37,830 command should be present here on 140 00:05:37,830 --> 00:05:40,110 this list. Let me scroll a bit up 141 00:05:40,110 --> 00:05:42,090 and here was this command 'uptime'. 142 00:05:42,300 --> 00:05:44,610 Let's press Enter. And you'll see 143 00:05:44,640 --> 00:05:47,730 uptime of this Linux container, it 144 00:05:47,730 --> 00:05:51,570 is up around six minutes. Also, it 145 00:05:51,570 --> 00:05:54,690 has such commands as 'mkdir', you're 146 00:05:54,690 --> 00:05:56,280 able to create a new folder. For 147 00:05:56,280 --> 00:05:58,110 example, let's create 'my- 148 00:05:58,170 --> 00:06:00,540 folder'. Let's 'cd' into 'my-folder'. 149 00:06:01,260 --> 00:06:03,360 And here let's create a new file 150 00:06:03,480 --> 00:06:06,900 'touch file.txt'. And you'll see 151 00:06:06,900 --> 00:06:10,080 that new file was created. It means 152 00:06:10,080 --> 00:06:12,930 that this container has a really 153 00:06:12,960 --> 00:06:14,970 nice set of utilities that you are 154 00:06:15,000 --> 00:06:17,250 able to use out of the box. Also, 155 00:06:17,250 --> 00:06:18,750 if you want, you're able to install 156 00:06:18,780 --> 00:06:20,280 additional utilities if you need to 157 00:06:20,280 --> 00:06:22,710 do so. But what is actually BusyBox? 158 00:06:23,100 --> 00:06:25,230 BusyBox is a really small 159 00:06:25,560 --> 00:06:28,320 distribution that has a really 160 00:06:28,380 --> 00:06:30,330 large set of utilities, but those 161 00:06:30,360 --> 00:06:32,670 utilities are custom, and they are 162 00:06:32,670 --> 00:06:35,130 actually really small in size. And 163 00:06:35,130 --> 00:06:37,860 usually this BusyBox installation 164 00:06:37,890 --> 00:06:39,840 is packaged as a single executable 165 00:06:39,840 --> 00:06:41,970 file. And now let's have a look at 166 00:06:41,970 --> 00:06:44,610 the size of this busybox image in 167 00:06:44,610 --> 00:06:47,280 comparison to ubuntu image. Let's 168 00:06:47,310 --> 00:06:50,700 exit this container like so. And if 169 00:06:50,700 --> 00:06:52,290 I list the containers that are 170 00:06:52,290 --> 00:06:53,640 running right now, you'll see that 171 00:06:53,670 --> 00:06:55,410 there are no containers. Let me do 172 00:06:55,410 --> 00:06:58,860 that. 'docker ps'. Yes, there are no 173 00:06:58,860 --> 00:07:00,270 containers currently running, 174 00:07:00,420 --> 00:07:03,120 because we have exited the 'sh' 175 00:07:03,150 --> 00:07:04,920 process, and container was 176 00:07:04,920 --> 00:07:06,840 automatically terminated. And if 177 00:07:06,840 --> 00:07:08,850 I'll have a look at the history, 178 00:07:08,880 --> 00:07:10,770 you'll see that there was busybox 179 00:07:10,770 --> 00:07:12,930 container that was exited 19 180 00:07:12,960 --> 00:07:15,180 seconds ago. Great. I wanted to 181 00:07:15,180 --> 00:07:17,310 show you size of busybox container. 182 00:07:17,580 --> 00:07:19,680 Let's clear terminal and list local 183 00:07:19,710 --> 00:07:23,160 images, 'docker images'. And you'll 184 00:07:23,160 --> 00:07:24,990 see a ubuntu, busybox, 185 00:07:24,990 --> 00:07:27,240 hello-world here on the list. And 186 00:07:27,270 --> 00:07:29,100 now have a look at the size of 187 00:07:29,100 --> 00:07:32,010 busybox image. It is a bit larger 188 00:07:32,070 --> 00:07:35,310 than one megabyte. In comparison to 189 00:07:35,340 --> 00:07:38,640 ubuntu size this size is really 190 00:07:38,670 --> 00:07:42,420 really insanely small. That's the 191 00:07:42,420 --> 00:07:45,390 smallest Linux container available. 192 00:07:45,840 --> 00:07:47,970 It has again a built in set of 193 00:07:47,970 --> 00:07:49,650 utilities, and you are able to use 194 00:07:49,650 --> 00:07:52,500 them but it is much much much more 195 00:07:52,500 --> 00:07:55,920 smaller than ubuntu image. Great. 196 00:07:56,160 --> 00:07:58,260 That's how you're able to create 197 00:07:58,530 --> 00:08:01,230 containers using busybox image. 198 00:08:01,620 --> 00:08:03,330 Let's now proceed, and next let me 199 00:08:03,330 --> 00:08:05,640 show you one more image that is 200 00:08:05,640 --> 00:08:08,730 based actually on busybox image, and 201 00:08:08,730 --> 00:08:11,250 that image is called alpine. Let's 202 00:08:11,250 --> 00:08:12,930 have a look at it next. Bye-Bye. 203 00:08:12,930 --> 00:08:15,445 [no audio]