1 00:00:00,017 --> 00:00:03,017 [Intro Music] 2 00:00:04,440 --> 00:00:06,390 We have just explored the image 3 00:00:06,390 --> 00:00:09,090 called BusyBox. BusyBox is 4 00:00:09,090 --> 00:00:11,250 basically not a full feature of the 5 00:00:11,250 --> 00:00:13,860 Linux operating system. Instead, it 6 00:00:13,860 --> 00:00:17,310 is just a set of Linux utils. And 7 00:00:17,310 --> 00:00:18,690 now in this lecture I will 8 00:00:18,690 --> 00:00:20,610 demonstrate you how to use another 9 00:00:20,610 --> 00:00:23,280 image called Alpine. And let's 10 00:00:23,280 --> 00:00:25,860 first try to pull this image using 11 00:00:25,920 --> 00:00:28,140 'docker pull' command. We have not 12 00:00:28,140 --> 00:00:29,760 used this command before, but this 13 00:00:29,760 --> 00:00:32,460 command will simply pull image from 14 00:00:32,490 --> 00:00:34,890 Remote Registry Docker Hub. Let's 15 00:00:34,890 --> 00:00:36,450 do that. At the moment, we actually 16 00:00:36,450 --> 00:00:38,760 have three images, ubuntu, busybox, 17 00:00:38,760 --> 00:00:40,710 and hello-world. And now let's pull 18 00:00:40,740 --> 00:00:46,920 one more image, 'docker pull alpine' 19 00:00:47,310 --> 00:00:50,460 without any tags, just 'alpine'. And 20 00:00:50,460 --> 00:00:51,750 you see that we are using the 21 00:00:51,750 --> 00:00:53,730 default tag 'latest', and we are 22 00:00:53,730 --> 00:00:56,250 pulling this image from Docker Hub. 23 00:00:56,580 --> 00:00:59,250 Image was pulled, here is its SHA 24 00:00:59,370 --> 00:01:02,880 256 Hash. And if I repeat the same 25 00:01:02,880 --> 00:01:05,099 command again, 'docker pull alpine', 26 00:01:05,310 --> 00:01:07,170 you'll see that Docker server will 27 00:01:07,170 --> 00:01:09,270 try to pull the same image again, 28 00:01:09,420 --> 00:01:11,610 but you'll see status that 'Image is 29 00:01:11,640 --> 00:01:13,950 up to date for alpine:latest'. 30 00:01:14,220 --> 00:01:16,500 Basically all what happens here, in 31 00:01:16,500 --> 00:01:18,960 this case, we are comparing those 32 00:01:18,960 --> 00:01:21,540 hashes, this one and this one, and if 33 00:01:21,570 --> 00:01:24,030 the image Docker decides that we 34 00:01:24,060 --> 00:01:26,640 already have latest image available 35 00:01:26,700 --> 00:01:29,520 locally in a local hash, and if I 36 00:01:29,520 --> 00:01:32,010 list images, local images now 37 00:01:32,070 --> 00:01:35,580 'docker images', you'll see this new 38 00:01:35,610 --> 00:01:38,070 image, 'alpine' on the list. That is 39 00:01:38,070 --> 00:01:40,770 latest IMAGE ID is here, CREATED 40 00:01:40,770 --> 00:01:44,430 '2 weeks ago', and its SIZE is 5.6 41 00:01:44,460 --> 00:01:47,250 megabytes. Notice that the alpine 42 00:01:47,280 --> 00:01:49,950 image is larger than busybox 43 00:01:49,980 --> 00:01:52,680 image, busybox image was a bit 44 00:01:52,890 --> 00:01:56,181 larger than one megabyte, but alpine 45 00:01:56,181 --> 00:01:58,380 is still much much smaller 46 00:01:58,470 --> 00:02:01,290 than ubuntu image, that is 64 47 00:02:01,320 --> 00:02:04,320 megabytes in size. Now let's try to 48 00:02:04,320 --> 00:02:06,330 create a new container based on 49 00:02:06,360 --> 00:02:08,970 alpine image. And afterwards, I'll 50 00:02:08,970 --> 00:02:10,650 create one more container with 51 00:02:10,650 --> 00:02:12,750 busybox image. And I'll try to 52 00:02:12,750 --> 00:02:14,940 compare those two images and show 53 00:02:14,940 --> 00:02:16,920 you differences between them. But 54 00:02:16,920 --> 00:02:19,080 basically, alpine is based on 55 00:02:19,080 --> 00:02:20,820 busybox; and again, I'll prove it 56 00:02:20,820 --> 00:02:22,470 to you in this lecture. Okay, 57 00:02:22,470 --> 00:02:25,410 great. Let's first create a new container 58 00:02:25,410 --> 00:02:28,380 based on alpine image. Let's 59 00:02:28,410 --> 00:02:31,410 create it like so, 'docker run - 60 00:02:31,410 --> 00:02:34,560 it', because I need to get into 'ch' 61 00:02:34,590 --> 00:02:37,080 shell inside of this container. And 62 00:02:37,110 --> 00:02:39,270 let's type here name of the image 63 00:02:39,300 --> 00:02:42,120 'alpine' like so. Container was 64 00:02:42,120 --> 00:02:43,860 created. And I have automatically 65 00:02:43,890 --> 00:02:46,260 logged into ch shell inside of that 66 00:02:46,260 --> 00:02:48,540 container. Let's use ls command 67 00:02:48,540 --> 00:02:49,980 here and you'll see a set of 68 00:02:49,980 --> 00:02:51,870 folders inside of alpine 69 00:02:51,870 --> 00:02:54,120 container. Great. Let's in 70 00:02:54,120 --> 00:02:56,280 parallel, create one more container 71 00:02:56,340 --> 00:02:58,350 and it will be busybox container. 72 00:02:58,650 --> 00:03:00,840 Let me open up a new tab here. And 73 00:03:00,870 --> 00:03:02,850 let's create a new container 'docker 74 00:03:02,850 --> 00:03:06,200 run -it' again, and here will be 'busybox'. 75 00:03:07,560 --> 00:03:09,480 Again, I have logged into ch shell 76 00:03:09,480 --> 00:03:11,400 inside of that container. And if I 77 00:03:11,400 --> 00:03:13,890 list the folders here, you will see 78 00:03:13,920 --> 00:03:16,200 less folders than we have seen here 79 00:03:16,260 --> 00:03:19,200 in alpine container. Now, let's do the 80 00:03:19,200 --> 00:03:21,120 following. Let's try to explore a 81 00:03:21,120 --> 00:03:23,520 version of Linux operating system 82 00:03:23,520 --> 00:03:25,350 here in this container, alpine 83 00:03:25,350 --> 00:03:27,390 container. Let me clear terminal, and 84 00:03:27,420 --> 00:03:31,304 type 'cat /etc/os-release'. 85 00:03:31,304 --> 00:03:32,880 And I'll see release 86 00:03:32,880 --> 00:03:34,950 version of this container. It is 87 00:03:34,980 --> 00:03:38,368 Alpine Linux version 3.11. 88 00:03:38,368 --> 00:03:40,080 And that proves that this 89 00:03:40,080 --> 00:03:41,760 container is basically running 90 00:03:41,850 --> 00:03:44,160 Linux operating system. And here 91 00:03:44,160 --> 00:03:46,260 is the link, you could copy this link, 92 00:03:46,290 --> 00:03:48,780 and go to your web browser. Let me 93 00:03:48,780 --> 00:03:51,540 do that quickly. Go to Google 94 00:03:51,540 --> 00:03:54,420 Chrome, and paste link here, and on 95 00:03:54,420 --> 00:03:56,610 this page you're basically able to 96 00:03:56,610 --> 00:03:59,190 read the details about Alpine Linux, 97 00:03:59,220 --> 00:04:01,440 what is that? And here you actually 98 00:04:01,440 --> 00:04:03,450 see that Alpine Linux is security- 99 00:04:03,450 --> 00:04:05,700 oriented, lightweight Linux 100 00:04:05,700 --> 00:04:08,190 distribution based on musl libc 101 00:04:08,190 --> 00:04:11,670 and busybox. Okay, now let me show 102 00:04:11,670 --> 00:04:14,460 you why alpine is actually based on 103 00:04:14,460 --> 00:04:16,230 busybox and how you're able to 104 00:04:16,230 --> 00:04:19,680 verify that. Let's list files in 'bin' 105 00:04:19,680 --> 00:04:22,500 folder, 'ls bin'; and you'll see here 106 00:04:22,500 --> 00:04:26,490 bunch of actually links to BusyBox 107 00:04:26,640 --> 00:04:29,520 utilities. Let me execute the same 108 00:04:29,520 --> 00:04:31,680 command as I had executed before, I mean 109 00:04:31,680 --> 00:04:34,440 'cat /etc/os-release' in busybox 110 00:04:34,440 --> 00:04:36,720 container. Let's go to this tab 111 00:04:36,750 --> 00:04:38,970 where we have started busybox and 112 00:04:38,970 --> 00:04:43,265 let's type 'cat /etc/os-release', 113 00:04:43,265 --> 00:04:44,250 same command as we 114 00:04:44,250 --> 00:04:45,780 have just entered in alpine 115 00:04:45,780 --> 00:04:48,510 container, Enter, and you'll see this 116 00:04:48,510 --> 00:04:51,857 error, can't open '/etc/os-release': 117 00:04:51,857 --> 00:04:53,490 No such file or directory, 118 00:04:53,490 --> 00:04:56,500 and that proves that BusyBox is not 119 00:04:56,520 --> 00:04:58,680 basically a full featured Linux 120 00:04:58,710 --> 00:05:00,630 operating system, it is just a set of 121 00:05:00,630 --> 00:05:03,780 utilities, nothing else. Let's 122 00:05:03,780 --> 00:05:05,910 basically compare the contents of 123 00:05:05,940 --> 00:05:07,950 'etc' folder here in busybox 124 00:05:07,950 --> 00:05:09,990 container and alpine container. 125 00:05:10,320 --> 00:05:14,340 Let's list files here, 'ls etc'; and 126 00:05:14,340 --> 00:05:18,090 let's list files here, 'ls etc'; and 127 00:05:18,090 --> 00:05:20,310 you'll see here much more files and 128 00:05:20,310 --> 00:05:22,560 folders than we have seen here in 129 00:05:22,560 --> 00:05:25,410 this output in busybox container. 130 00:05:26,190 --> 00:05:28,740 Okay, let's now try to compare 131 00:05:28,800 --> 00:05:30,960 contents of the 'bin' folders here 132 00:05:30,960 --> 00:05:33,660 and here. Let's list files here in 133 00:05:33,660 --> 00:05:36,150 'bin' folder; and let's list files 134 00:05:36,180 --> 00:05:40,140 here in busybox, 'ls bin'. You'll see 135 00:05:40,140 --> 00:05:42,720 here much more actually files in 136 00:05:42,780 --> 00:05:46,020 busybox container than here. But if 137 00:05:46,020 --> 00:05:49,710 you execute the 'ls -la' command 138 00:05:49,800 --> 00:05:52,230 'bin', you'll see that all commands 139 00:05:52,230 --> 00:05:54,540 here in alpine container are 140 00:05:54,540 --> 00:05:57,630 basically shortcuts for busybox 141 00:05:57,630 --> 00:06:00,090 commands. You see that, for 142 00:06:00,090 --> 00:06:02,700 example, 'ps' command is shortcut, 143 00:06:02,760 --> 00:06:06,030 and it links us to '/bin/busybox' 144 00:06:06,150 --> 00:06:09,000 executable script. Let me show you 145 00:06:09,000 --> 00:06:11,010 something. If you simply type 146 00:06:11,040 --> 00:06:13,710 'busybox' here in alpine container, 147 00:06:13,890 --> 00:06:16,350 you'll see actually description of 148 00:06:16,380 --> 00:06:19,620 busybox commands. And if you scroll 149 00:06:19,650 --> 00:06:21,480 up, you may read that the 'BusyBox 150 00:06:21,510 --> 00:06:22,770 is a multi-call binary that 151 00:06:22,770 --> 00:06:24,720 combines many common Unix utilities 152 00:06:24,750 --> 00:06:27,540 into a single executable'; and this 153 00:06:27,540 --> 00:06:30,450 executable is included into alpine 154 00:06:30,450 --> 00:06:32,670 container. That's that simple. 155 00:06:32,940 --> 00:06:35,460 That's why you are able to use all 156 00:06:35,460 --> 00:06:37,320 commands that are available in 157 00:06:37,320 --> 00:06:39,210 busybox inside of the alpine 158 00:06:39,210 --> 00:06:41,490 container, because of those hard 159 00:06:41,490 --> 00:06:43,350 coded links. For example, this 160 00:06:43,350 --> 00:06:47,070 command 'sed', links to be busybox 161 00:06:47,070 --> 00:06:49,590 command, and so on. You could 162 00:06:49,590 --> 00:06:52,410 actually try to do that. And for 163 00:06:52,410 --> 00:06:55,800 example, let's read the help for 'ifconfig' 164 00:06:55,800 --> 00:06:58,100 command. 'ifconfig -- 165 00:06:58,170 --> 00:07:00,750 help. You'll see this output - 166 00:07:00,810 --> 00:07:04,170 BusyBox v1.31.1, and 167 00:07:04,170 --> 00:07:06,930 so on. And description of options 168 00:07:06,930 --> 00:07:09,660 for 'ifconfig' command. If I will do 169 00:07:09,660 --> 00:07:11,683 the same in busybox container, 170 00:07:11,683 --> 00:07:15,690 'ifconfig --help', you'll 171 00:07:15,690 --> 00:07:17,610 see actually exactly the same 172 00:07:17,640 --> 00:07:21,355 result - BusyBox v1.31.1, 173 00:07:21,355 --> 00:07:23,760 and so on. Same result as 174 00:07:23,760 --> 00:07:26,130 here. And again, that proves that 175 00:07:26,190 --> 00:07:29,520 alpine image is based on busybox 176 00:07:29,550 --> 00:07:31,200 image. But there are some 177 00:07:31,230 --> 00:07:34,290 additional folders and files that 178 00:07:34,290 --> 00:07:36,210 make alpine image basically a 179 00:07:36,210 --> 00:07:37,980 fully featured Linux operating 180 00:07:37,980 --> 00:07:40,560 system. That's how it looks like in 181 00:07:40,560 --> 00:07:42,510 comparison between alpine and 182 00:07:42,510 --> 00:07:45,690 busybox images. Great. What else I 183 00:07:45,690 --> 00:07:47,520 wanted to show you. Let me also 184 00:07:47,520 --> 00:07:49,500 list the contents of the 'sbin' 185 00:07:49,500 --> 00:07:51,690 folder here in alpine container. 186 00:07:52,410 --> 00:07:56,042 Let me actually use 'ls -la sbin'. 187 00:07:56,042 --> 00:07:58,110 And also in this folder, you 188 00:07:58,110 --> 00:08:00,270 will see that there are a bunch of 189 00:08:00,540 --> 00:08:03,000 actually links to '/bin/ 190 00:08:03,030 --> 00:08:06,660 busybox'. Like reboot, that points to 191 00:08:06,660 --> 00:08:09,510 '/bin/busybox'; 'poweroff', and so on. 192 00:08:09,780 --> 00:08:12,600 But if I scroll a bit up, let me do 193 00:08:12,600 --> 00:08:14,730 that, you'll see additional scripts 194 00:08:14,760 --> 00:08:19,590 like 'ldconfig', 'mkmntdirs', and 195 00:08:19,590 --> 00:08:22,170 also you should see here 'apk' 196 00:08:22,200 --> 00:08:24,060 script, let me scroll a bit up, 197 00:08:24,090 --> 00:08:26,070 yes here it is. And with this 198 00:08:26,070 --> 00:08:27,780 script, you are able to install 199 00:08:27,810 --> 00:08:29,820 additional packages inside of the 200 00:08:29,970 --> 00:08:32,820 alpine container. And if you enter 201 00:08:32,880 --> 00:08:35,340 'apk --help', you'll see 202 00:08:35,340 --> 00:08:38,010 actually help for 'APK' command. And 203 00:08:38,039 --> 00:08:40,140 if you scroll up, you'll see that 204 00:08:40,169 --> 00:08:42,480 there is no information about 205 00:08:42,480 --> 00:08:45,360 BusyBox at the top. This is because 206 00:08:45,390 --> 00:08:48,030 this script was added additionally 207 00:08:48,059 --> 00:08:50,520 to scripts built in into BusyBox. 208 00:08:51,030 --> 00:08:53,159 And if I'll go to BusyBox here and 209 00:08:53,190 --> 00:08:55,860 enter 'apk', I will get answer 210 00:08:55,890 --> 00:08:58,050 'apk: not found'. And that's because 211 00:08:58,080 --> 00:09:00,300 'apk' is absent by default in 212 00:09:00,330 --> 00:09:03,000 BusyBox. Great. Let me also show 213 00:09:03,000 --> 00:09:04,710 you how you're able to start 214 00:09:04,710 --> 00:09:07,860 specific scripts using busybox 215 00:09:07,890 --> 00:09:11,100 scripts. For example, let me clear 216 00:09:11,100 --> 00:09:13,020 terminal and type here, I am now in 217 00:09:13,020 --> 00:09:16,800 alpine container, 'busybox ifconfig', 218 00:09:17,800 --> 00:09:19,800 and you'll get a result of 'ifconfig' 219 00:09:19,800 --> 00:09:21,900 command using busybox 220 00:09:21,960 --> 00:09:24,450 script. And again that proves that 221 00:09:24,450 --> 00:09:26,160 busybox is just a set of 222 00:09:26,160 --> 00:09:28,050 utilities and you are able to use 223 00:09:28,080 --> 00:09:30,870 those utilities like so. Or let's 224 00:09:30,870 --> 00:09:34,596 use busybox, for example, 'traceroute' 225 00:09:34,596 --> 00:09:36,420 command and here let's trace 226 00:09:36,420 --> 00:09:40,050 route path to google.com. It seems 227 00:09:40,110 --> 00:09:41,790 that something is broken on a way 228 00:09:41,940 --> 00:09:44,100 but anyway let's for example use 229 00:09:44,640 --> 00:09:49,500 ping instead of traceroute, and you 230 00:09:49,500 --> 00:09:51,600 will see answer from google.com web 231 00:09:51,600 --> 00:09:54,120 server. And also you are able to do 232 00:09:54,120 --> 00:09:56,220 following. You are able to use ping 233 00:09:56,250 --> 00:09:59,310 without busybox prefix. Simply, 234 00:09:59,310 --> 00:10:01,380 'ping google.com', and you'll get 235 00:10:01,380 --> 00:10:03,120 the same result. And the reason for 236 00:10:03,120 --> 00:10:06,120 that is that ping is simply link to 237 00:10:06,120 --> 00:10:08,340 'busybox ping'. Let me show you that 238 00:10:08,550 --> 00:10:11,250 'ls bin', and you'll see ping here 239 00:10:11,280 --> 00:10:13,140 on the list, but in order to verify 240 00:10:13,140 --> 00:10:14,730 that it is actually linked to 241 00:10:14,730 --> 00:10:18,060 busybox, you could use 'ls -la 242 00:10:18,420 --> 00:10:22,470 bin'; and if you scroll up, you'll 243 00:10:22,470 --> 00:10:24,750 see that ping is simply link to 244 00:10:24,780 --> 00:10:27,600 '/bin/busybox'. That's that simple. 245 00:10:28,440 --> 00:10:30,750 Great. That's the comparison of 246 00:10:30,780 --> 00:10:33,540 busybox and alpine. And actually, 247 00:10:33,570 --> 00:10:36,510 alpine is a very popular choice for 248 00:10:36,510 --> 00:10:38,340 creation of additional images, 249 00:10:38,340 --> 00:10:40,470 custom images, it is really small 250 00:10:40,470 --> 00:10:43,260 in size, it is a bit more than five 251 00:10:43,290 --> 00:10:44,760 megabytes. Let me show you it 252 00:10:44,760 --> 00:10:46,830 again. Actually, now I'm located in 253 00:10:46,860 --> 00:10:49,200 alpine container, and I need to go 254 00:10:49,200 --> 00:10:51,510 out of it. Actually, let me open up 255 00:10:51,570 --> 00:10:53,850 a new tab and list images here, 256 00:10:53,880 --> 00:10:56,430 'docker images', and here you'll see 257 00:10:56,460 --> 00:10:59,850 sizes for alpine image, for busybox 258 00:10:59,880 --> 00:11:02,550 image, and for ubuntu image. Let's 259 00:11:02,550 --> 00:11:04,200 shortly summarize what we have 260 00:11:04,200 --> 00:11:06,540 explored here in this lecture. We 261 00:11:06,540 --> 00:11:08,610 have compared alpine and busybox 262 00:11:08,610 --> 00:11:10,500 images. And you have see that the 263 00:11:10,500 --> 00:11:12,810 BusyBox is basically just a set of 264 00:11:12,870 --> 00:11:15,840 utilities, nothing else; and Alpine 265 00:11:15,870 --> 00:11:17,490 is full feature of the operating 266 00:11:17,490 --> 00:11:19,710 system, that's called Alpine Linux, 267 00:11:19,890 --> 00:11:22,320 but it's based on BusyBox; and it 268 00:11:22,320 --> 00:11:24,720 reuses utilities that are included 269 00:11:24,750 --> 00:11:27,360 in BusyBox. But it also has some 270 00:11:27,390 --> 00:11:28,950 additional features. For example, 271 00:11:28,950 --> 00:11:31,500 it has 'apk' utility that allows 272 00:11:31,500 --> 00:11:33,240 you to install additional packages 273 00:11:33,270 --> 00:11:35,160 or modules inside of the operating 274 00:11:35,160 --> 00:11:37,680 system. And Alpine is very often 275 00:11:37,680 --> 00:11:40,590 used as a base layer for custom 276 00:11:40,590 --> 00:11:43,230 images. Okay, I hope you enjoyed 277 00:11:43,230 --> 00:11:44,730 this comparison, and now you 278 00:11:44,730 --> 00:11:45,960 understand difference between 279 00:11:45,960 --> 00:11:47,970 Alpine and BusyBox, and now you 280 00:11:47,970 --> 00:11:49,590 should understand that there was no 281 00:11:49,620 --> 00:11:51,660 need to use such large images, 282 00:11:51,660 --> 00:11:53,550 for example, like ubuntu, that is 283 00:11:53,550 --> 00:11:55,800 much much larger than alpine or 284 00:11:55,800 --> 00:11:58,140 busybox. And if you just need the 285 00:11:58,290 --> 00:12:00,420 Linux command line and some basic 286 00:12:00,420 --> 00:12:02,610 utilities, you could go ahead with 287 00:12:02,670 --> 00:12:05,040 Alpine. Okay, that's all for this 288 00:12:05,070 --> 00:12:07,020 large lecture. And in the next one 289 00:12:07,020 --> 00:12:08,910 let's proceed and explore some 290 00:12:08,910 --> 00:12:11,500 additional images. See you next bye-bye. 291 00:12:11,500 --> 00:12:14,200 [no audio]