1 00:00:00,910 --> 00:00:05,560 In this section we're going to continue looking at the darker run command or some slight variations 2 00:00:05,560 --> 00:00:06,250 of it. 3 00:00:06,430 --> 00:00:10,300 Now before I show you the next kind of variations command that we're going to look at I want to give 4 00:00:10,300 --> 00:00:11,730 you one quick reminder. 5 00:00:11,800 --> 00:00:16,900 Remember any time that we execute Docker run with an image we not only get that file system snapshot 6 00:00:17,050 --> 00:00:23,430 but we also get this default command that is supposed to be executed after the container is created. 7 00:00:23,500 --> 00:00:28,390 So the variation on Docker run that we're gonna look at is going to give you a way to override this 8 00:00:28,390 --> 00:00:34,690 default startup command here's how we do it will execute Docker run the image name just like we did 9 00:00:34,690 --> 00:00:40,840 before and then after that we'll supply a alternate command to be executed inside the container after 10 00:00:40,840 --> 00:00:41,950 it starts up. 11 00:00:41,950 --> 00:00:43,240 This is an override. 12 00:00:43,300 --> 00:00:47,940 So whatever default command is included inside of the image is not going to be executed. 13 00:00:47,950 --> 00:00:50,520 Let's try this out right now and just see how it works. 14 00:00:50,560 --> 00:00:50,800 All right. 15 00:00:50,830 --> 00:00:57,530 So I'm going to find my terminal and I'm going to execute Docker run and I'm going to specify my image. 16 00:00:57,550 --> 00:01:00,150 We're going to use a different image than what we used before. 17 00:01:00,220 --> 00:01:02,230 We're going to use an image called Busy Box. 18 00:01:02,230 --> 00:01:08,080 And I'll tell you why in just a moment after that we'll list out the alternate command to execute inside 19 00:01:08,080 --> 00:01:10,180 the container after it is created. 20 00:01:10,180 --> 00:01:16,690 And so I'm going to say that I want to run a command echo Hi there so this right here is the override. 21 00:01:16,690 --> 00:01:19,720 This is a command they'll be executed inside that container. 22 00:01:19,720 --> 00:01:21,480 The Echo command is going to print out. 23 00:01:21,490 --> 00:01:22,000 Hi. 24 00:01:22,060 --> 00:01:22,990 Inside my terminal. 25 00:01:23,170 --> 00:01:27,330 So if this works the way we would expect I'll see the text high there appear. 26 00:01:27,380 --> 00:01:28,110 So going to run that. 27 00:01:28,120 --> 00:01:33,490 And sure enough yep we see that we can change the text provided here to the Echo command as much as 28 00:01:33,490 --> 00:01:34,180 we please. 29 00:01:34,180 --> 00:01:40,630 So I could say by there or I could say how are you. 30 00:01:40,630 --> 00:01:43,280 You get the idea now. 31 00:01:43,290 --> 00:01:46,060 I want to show you a small variation on that command. 32 00:01:46,150 --> 00:01:50,050 And this is going to start to make things a little bit more interesting than just kind of echoing Tex 33 00:01:50,050 --> 00:01:51,450 back over to you. 34 00:01:51,520 --> 00:01:57,250 I want you to run Docker run busy box and then the override command that we're going to use this time 35 00:01:57,280 --> 00:02:02,830 is going to be less if you never used Alice before it's going to print out all the files and folders 36 00:02:02,980 --> 00:02:05,060 inside of a given directory. 37 00:02:05,140 --> 00:02:11,860 So let's try running this and see what happens so according to our docker container when we print out 38 00:02:11,920 --> 00:02:18,520 our files and folders we have been at sea Dev home proc Root says temp user ID var. 39 00:02:18,520 --> 00:02:20,550 These are all folders right here. 40 00:02:20,650 --> 00:02:25,810 And if you are on say a Windows machine right here these folders might look very strange to you and 41 00:02:25,810 --> 00:02:27,620 very unfamiliar. 42 00:02:27,670 --> 00:02:34,260 So in fact these are folders that are being printed out that are not belonging to you on your computer. 43 00:02:34,270 --> 00:02:38,140 These are folders that exist solely inside that container. 44 00:02:38,140 --> 00:02:42,070 I want to remind you about exactly what happens when we create a container out of an image. 45 00:02:42,580 --> 00:02:44,690 So over here we've got the busy box image. 46 00:02:44,830 --> 00:02:50,870 It has some default files system snapshot and some presumably default command. 47 00:02:50,880 --> 00:02:55,860 You know who knows what it is off top of my head but it definitely has this default file system snapshot 48 00:02:56,440 --> 00:03:02,770 that busy box image has default folders of bin Dev Etsy home proc route and so on all the ones you see 49 00:03:02,830 --> 00:03:04,340 listed right here. 50 00:03:04,360 --> 00:03:12,490 So when we create a new container out of that image we take this file system snapshot we stick it in 51 00:03:12,610 --> 00:03:17,590 as the folder for that container and then the command that we execute is less. 52 00:03:17,710 --> 00:03:22,880 So we list out all the files and folders inside of our hard drive which then prints out bin Dev at the 53 00:03:22,880 --> 00:03:26,560 home proc and root so that's pretty much it. 54 00:03:26,580 --> 00:03:30,990 Now one thing you might be all a bit curious about is why we chose to use the busy box image here as 55 00:03:30,990 --> 00:03:34,310 opposed to the hello world one that we were using before. 56 00:03:34,320 --> 00:03:36,570 Well let's go back over to our terminal really quickly. 57 00:03:36,600 --> 00:03:42,870 We're going to try running hello world with the LDS command so I'll do Docker run Hello dash world and 58 00:03:42,870 --> 00:03:48,370 I'll do El s right here and you're gonna very quickly see that we get a kind of nasty error message. 59 00:03:48,390 --> 00:03:51,700 Well let's try doing the echo command and see what happens. 60 00:03:51,930 --> 00:03:55,460 I'll do Docker run hello world echo Hi there. 61 00:03:55,470 --> 00:03:57,970 And we get a very similar error message here as well. 62 00:03:58,200 --> 00:03:59,640 So what's going on. 63 00:03:59,640 --> 00:04:00,570 Well here's the issue. 64 00:04:01,530 --> 00:04:07,830 When we run the alternate commands or those alternate echo and Ellis commands with busy box those commands 65 00:04:07,830 --> 00:04:17,250 work because Ellis and Echo are two programs that exist inside of the busy box file system image somewhere 66 00:04:17,340 --> 00:04:24,720 inside of this folder system right here is a Ellis command or an actual LDS executable and a echo executable 67 00:04:24,750 --> 00:04:25,680 as well. 68 00:04:25,770 --> 00:04:30,870 And so we can safely execute those commands with busy box because those are programs that exist inside 69 00:04:30,870 --> 00:04:32,400 this file system. 70 00:04:32,460 --> 00:04:39,090 However with our hello world program over here the only thing that exists inside this file system snapshot 71 00:04:39,300 --> 00:04:46,320 is a single program like one single file and all that thing does is echo out or kind of print out that 72 00:04:46,320 --> 00:04:49,350 singular message that we saw when we ran that container. 73 00:04:49,350 --> 00:04:55,110 So these startup commands that we are executing are being based upon the file system include with the 74 00:04:55,110 --> 00:04:55,560 image. 75 00:04:55,590 --> 00:05:01,320 And if we tried to execute a command inside the container that uses a program that doesn't or is not 76 00:05:01,410 --> 00:05:05,330 contained within this file system we're going to see that error. 77 00:05:05,370 --> 00:05:05,640 OK. 78 00:05:05,730 --> 00:05:08,670 So a little bit more on Docker on command. 79 00:05:08,670 --> 00:05:11,490 Let's take another quick break right now and continue in the next section.