1 00:00:01,440 --> 00:00:04,830 In this video we're going to do a quick overview of some very basic Docker commands. 2 00:00:04,830 --> 00:00:06,900 Just make sure these are fresh in your mind. 3 00:00:06,900 --> 00:00:10,980 We're going to be running all the commands you see here quite a bit and also running some variance of 4 00:00:10,980 --> 00:00:13,220 them that are based on Cuban eddies as opposed to Docker. 5 00:00:13,230 --> 00:00:15,390 But don't worry about that part just yet. 6 00:00:15,390 --> 00:00:18,420 So first command we're going to get a quick reminder on is darker build. 7 00:00:18,450 --> 00:00:23,640 We did just run this last video but just as a reminder whenever we build a new image we can add on that 8 00:00:23,640 --> 00:00:27,120 dash t flag that will tag the image that is created. 9 00:00:27,120 --> 00:00:32,670 If we add on the dash t then we can easily create a new container at a image using either the image 10 00:00:32,670 --> 00:00:34,640 I.D. or the image tag. 11 00:00:34,650 --> 00:00:43,310 So for example if we go back over to our post service we can do a docker build a dash T and then usually 12 00:00:43,310 --> 00:00:48,620 we'll put in our Docker I.D. which for me is Steven greater flash and then the name of our project. 13 00:00:48,620 --> 00:00:54,050 So for us to be posts then after that we'd put in a dot to specify that we want to build this image 14 00:00:54,320 --> 00:00:55,820 out of the current directory that we're in. 15 00:00:56,630 --> 00:01:01,400 So I would run that the build runs very quickly because I've not made any changes to it from the last 16 00:01:01,400 --> 00:01:07,170 video and now I can create an image out personally a container of this image using either the image 17 00:01:07,170 --> 00:01:15,350 I.D. That's right there or the tag that is right there once we have built the image we can create and 18 00:01:15,350 --> 00:01:21,110 start a container based on it by using Docker run and then providing either the image I.D. or the tag. 19 00:01:21,110 --> 00:01:29,930 So for example I could now do Docker run Steven Greider slash posts like so and there we go there's 20 00:01:29,930 --> 00:01:33,430 our post service. 21 00:01:33,640 --> 00:01:39,730 Next up whenever we start up a container we can either just use Docker and by itself or alternatively 22 00:01:39,790 --> 00:01:46,640 we can override the default command of the container by providing both that I.T. flag right there and 23 00:01:46,640 --> 00:01:51,290 then the command that we want to execute instead the default one right there at the very end. 24 00:01:51,310 --> 00:01:56,620 So for example I could start up that postal service container that we just created and start up a shell 25 00:01:56,650 --> 00:01:57,310 inside there. 26 00:01:57,310 --> 00:02:01,930 So essentially a terminal window inside that container rather than actually running the default command 27 00:02:01,960 --> 00:02:03,730 which is NPM starts. 28 00:02:03,730 --> 00:02:11,210 So we could do a docker run dash I.T. Steven Greider posts and I would put an S H which will start up 29 00:02:11,270 --> 00:02:14,210 a shell inside there s h is short for the word shell. 30 00:02:14,210 --> 00:02:19,460 It is a very specific type of shell essentially equivalent to if you're running bash right now on your 31 00:02:19,460 --> 00:02:21,440 computer. 32 00:02:21,490 --> 00:02:26,650 And so now rather than running our server inside there I've got a shell running and inside of here I 33 00:02:26,650 --> 00:02:31,030 can run a typical commands all being executed inside of that container. 34 00:02:31,030 --> 00:02:36,520 So if I do an L S I'll see all of the files that have been built inside of that image or again change 35 00:02:36,520 --> 00:02:42,070 to the or seeing the container where I can change my root directory and prints out all the files and 36 00:02:42,070 --> 00:02:49,620 folders inside of their and then if I want to exit I can hit command D I always smash commands or control 37 00:02:49,620 --> 00:02:57,210 C out of habit but control or command D OK next comment. 38 00:02:57,580 --> 00:03:01,810 Docker P.S. we can use this to print out information about all the containers that we are currently 39 00:03:01,810 --> 00:03:02,950 running. 40 00:03:02,950 --> 00:03:08,920 So for example if we start up a container in one terminal window and then open up a second terminal 41 00:03:08,920 --> 00:03:13,120 window into a docker PSN there we'll see the idea of the running container. 42 00:03:13,300 --> 00:03:16,810 The image it is using the command that was used to start it up. 43 00:03:16,870 --> 00:03:18,760 How long ago he was created and so on. 44 00:03:22,190 --> 00:03:26,410 Once a container is running we can also execute arbitrary commands inside of it. 45 00:03:26,420 --> 00:03:32,000 So for example we could do a docker exact dash I.T. then put in the container I.D. and then the command 46 00:03:32,000 --> 00:03:34,330 that we want to actually run inside there. 47 00:03:34,340 --> 00:03:39,740 So for example if I wanted to start up a shell inside of my running post service right now I could take 48 00:03:39,740 --> 00:03:47,380 that container I.D. I could do a docker exact dash I.T. within that I.D. And then once again run as 49 00:03:47,390 --> 00:03:47,780 H. 50 00:03:47,790 --> 00:03:50,010 And that will start up a shell inside that running container 51 00:03:54,640 --> 00:03:58,410 and then finally one more very useful command is Docker logs. 52 00:03:58,490 --> 00:04:03,920 This will printout all the logs that have been executed to be emitted by the primary process inside 53 00:04:03,980 --> 00:04:05,290 of that container. 54 00:04:05,300 --> 00:04:10,880 So for example if I flip back over I'm going to stop the running container 55 00:04:13,810 --> 00:04:17,740 all then start it back up but I'm not going to override the default command. 56 00:04:17,740 --> 00:04:22,670 So we'll do it a docker run even greater post. 57 00:04:22,830 --> 00:04:28,080 And so as soon as I start this up our primary process which is that NPM start command is emitting some 58 00:04:28,080 --> 00:04:30,060 different logs here over standard out. 59 00:04:30,060 --> 00:04:31,890 That's everything we see right here. 60 00:04:31,890 --> 00:04:37,460 I can get all that information printed out inside of a second terminal window by doing a docker. 61 00:04:37,470 --> 00:04:47,420 P.S. getting the new container I.D. and then a docker logs and provide the relevant container I.D. and 62 00:04:47,500 --> 00:04:54,050 that will essentially show me everything that primary process has emitted. 63 00:04:54,050 --> 00:04:57,940 So again just some very basic commands we are going to be using these commands quite a bit. 64 00:04:57,950 --> 00:05:02,810 And again we'll be running kind of variance of them in the Cuban 80s world in just a little bit as well 65 00:05:03,080 --> 00:05:08,480 to just inspect what's going on inside of all of our different containers Well at this point we have 66 00:05:08,480 --> 00:05:11,720 seen how to make use of Docker how to build an image. 67 00:05:11,720 --> 00:05:14,760 We've made an image out of just the post service. 68 00:05:14,760 --> 00:05:16,030 So let's take a quick pause right here. 69 00:05:16,040 --> 00:05:19,490 When we come back the next video we're going to take that darker file and darker ignore. 70 00:05:19,550 --> 00:05:23,150 And we're going to copy it over to all of our different other services as well.