1 00:00:00,540 --> 00:00:04,510 The run instruction will execute the command of your choosing while 2 00:00:04,510 --> 00:00:05,860 building the image. 3 00:00:05,860 --> 00:00:10,890 The command will be run exactly as if you had typed in a shell on the guest OS. 4 00:00:10,890 --> 00:00:15,100 You can use these commands to permanently update the contents of the image. 5 00:00:15,100 --> 00:00:17,560 Run is useful for installing dependencies or 6 00:00:17,560 --> 00:00:20,200 running a script in the container at build time. 7 00:00:20,200 --> 00:00:24,730 This pair of commands here both run the ubuntu apps get package manager. 8 00:00:24,730 --> 00:00:28,065 The first updates the list of available packages and 9 00:00:28,065 --> 00:00:31,642 the second uses that updated list to install python3. 10 00:00:31,642 --> 00:00:35,842 The form of one instruction shown here is called the shell form which will execute 11 00:00:35,842 --> 00:00:38,080 the given command using a shell like bash. 12 00:00:39,290 --> 00:00:42,340 You should use this form if there are environment variables or 13 00:00:42,340 --> 00:00:47,130 file name wild cards whose values you want substituted into the command. 14 00:00:47,130 --> 00:00:50,320 The second form of RUN is called the exec form. 15 00:00:50,320 --> 00:00:53,360 Let me convert this first instruction to exec form. 16 00:00:53,360 --> 00:00:56,570 We use JSON array syntax with square brackets. 17 00:00:59,240 --> 00:01:01,810 We'll surround each element with quotation marks and 18 00:01:01,810 --> 00:01:03,470 we'll separate the elements with commas. 19 00:01:04,950 --> 00:01:07,950 The first element should be the executable you want to run, 20 00:01:07,950 --> 00:01:10,500 in this case that's apt-get. 21 00:01:10,500 --> 00:01:13,500 All subsequent elements are arguments to that executable. 22 00:01:14,680 --> 00:01:19,050 The exec form just passes your parameters directly to the given executable 23 00:01:19,050 --> 00:01:22,370 without invoking a shell or doing any substitution. 24 00:01:22,370 --> 00:01:26,310 You should use the exec form if you want to be very precise about the arguments you 25 00:01:26,310 --> 00:01:28,410 pass to the executable. 26 00:01:28,410 --> 00:01:33,268 So to finish converting this one, we'll use update as our second argument and 27 00:01:33,268 --> 00:01:37,050 -y as our third. 28 00:01:37,050 --> 00:01:41,740 And this run instruction in exec form is identical in meaning to this run 29 00:01:41,740 --> 00:01:43,625 instruction in shell form.