1 00:00:00,810 --> 00:00:05,220 In last section we learned about the importance of the Dash 80 flag in this section. 2 00:00:05,220 --> 00:00:09,990 I want to tell you about one last use of the docker exact command and this use of it is probably going 3 00:00:09,990 --> 00:00:14,340 to be the most common that you're going to be making use of on your own personal projects. 4 00:00:14,550 --> 00:00:19,680 A very common thing that you're going to want to do when you are using Docker is to get shell access 5 00:00:19,710 --> 00:00:22,590 or terminal access to your running container. 6 00:00:22,590 --> 00:00:28,170 In other words you are going to want to run commands inside of your container without having to rerun 7 00:00:28,170 --> 00:00:32,220 it Docker exact Docker exact Docker exact again and again all day. 8 00:00:32,220 --> 00:00:37,740 So in this section I'm going to show you how you can open up a shell or terminal in the context of your 9 00:00:37,800 --> 00:00:39,480 running container. 10 00:00:39,570 --> 00:00:41,160 So here's what we're gonna do. 11 00:00:41,190 --> 00:00:44,170 I'm going to put back over to my terminal. 12 00:00:44,220 --> 00:00:47,910 I'm going to verify that I'm still running that Rudd bread is container. 13 00:00:48,000 --> 00:00:51,910 I'm going to open up a second terminal window inside of here. 14 00:00:51,960 --> 00:01:01,000 I'm going to run Docker P.S. and get my container I.D. and then I'm going to run a docker exec dash 15 00:01:01,040 --> 00:01:06,770 I.T. I'll put the container I.D. in and then here's the magic I'm going to put in S H. 16 00:01:06,770 --> 00:01:09,710 We'll talk about what s h is in just a second. 17 00:01:10,040 --> 00:01:14,690 I'm going to run that command and you'll see that I get the little LB over here once I'm in here. 18 00:01:14,720 --> 00:01:20,940 I can now start to type out typical commands that I would expect to be able to run in a UNIX environment. 19 00:01:20,960 --> 00:01:25,850 So for example I could change my directory to my home directory. 20 00:01:25,850 --> 00:01:27,880 I can list out the files and folders inside there. 21 00:01:27,890 --> 00:01:29,010 Nothing there right now. 22 00:01:29,030 --> 00:01:31,970 Let's try going back to the root directory of Slash. 23 00:01:32,360 --> 00:01:39,290 And then if I do an L S I'll see all the root files and folders of the container I could execute commands 24 00:01:39,290 --> 00:01:47,000 like Echo Hi there I can export variables environment variables like export B equals 5 and then echo 25 00:01:47,000 --> 00:01:47,390 that. 26 00:01:47,720 --> 00:01:54,380 So essentially when I make use of this Docker exact command with s h over here I get full terminal access 27 00:01:54,470 --> 00:02:00,140 inside the context of the container which is extremely powerful for debugging I could even do things 28 00:02:00,140 --> 00:02:06,350 like say run the docker CLIA directly or not Docker see all CLIA but read a c a lie and that starts 29 00:02:06,350 --> 00:02:13,380 up the red a c a lie and then when I'm all done I can hit control C and it looks like nothing's happening 30 00:02:13,470 --> 00:02:14,630 so quick shortcut here. 31 00:02:14,700 --> 00:02:19,710 If you ever are in a container and it feels like you can't hit control C to exit you can always try 32 00:02:19,760 --> 00:02:22,960 and command d to me control D to get out as well. 33 00:02:23,560 --> 00:02:25,920 All right so let's talk about what just happened there. 34 00:02:25,920 --> 00:02:29,000 So we ran Docker exact which we've seen several times before. 35 00:02:29,220 --> 00:02:31,140 And then we did S H. 36 00:02:31,230 --> 00:02:39,960 So what is S H S H is the name of a program and it's a program that has been executed inside that container. 37 00:02:39,960 --> 00:02:43,150 S H is a command processor or a shell. 38 00:02:43,260 --> 00:02:48,940 It's something that allows us to type commands in and have them be executed inside that container. 39 00:02:49,050 --> 00:02:54,380 You are already making use of a program very much like a search on your own computer. 40 00:02:54,540 --> 00:02:59,100 Chances are if you're on Mac OS you are probably using something like bash if you're on Windows you're 41 00:02:59,100 --> 00:03:01,830 probably using something like get bash or power show. 42 00:03:01,980 --> 00:03:04,500 Me personally I'm making use of Z shell. 43 00:03:04,500 --> 00:03:10,020 These are all programs that allow you to type commands into your terminal and have them be executed. 44 00:03:10,050 --> 00:03:16,200 And so when we start up SDH inside of our container that's just another command shell that we can use 45 00:03:16,200 --> 00:03:17,510 to execute commands. 46 00:03:18,690 --> 00:03:22,800 Traditionally a lot of the different containers that you're going to be working with are probably going 47 00:03:22,800 --> 00:03:29,400 to have the same each command or suite or something DSH program all ready included some more complete 48 00:03:29,400 --> 00:03:35,130 versions of containers or images are going to also have the bash command processor as well. 49 00:03:35,160 --> 00:03:39,950 So in some cases you can make use of batch directly in vast majority you're probably going to be able 50 00:03:39,950 --> 00:03:44,570 to run the shell inside there to start up a command prompt and type in some commands. 51 00:03:45,840 --> 00:03:46,110 OK. 52 00:03:46,140 --> 00:03:52,560 So again I think that you're probably going to be using Docker exact dash I.T. with s h as the command. 53 00:03:52,560 --> 00:03:52,940 Mm. 54 00:03:52,950 --> 00:03:56,620 Very very often when you start doing your own Docker development. 55 00:03:56,790 --> 00:03:57,240 All right. 56 00:03:57,240 --> 00:03:59,870 So we've spoken a whole bunch around Docker Seelye. 57 00:03:59,880 --> 00:04:01,230 Let's take one more break here. 58 00:04:01,230 --> 00:04:05,130 There's just one or two quick topics I want to talk about and we'll start to move on to our next big 59 00:04:05,130 --> 00:04:05,580 topic.