1 00:00:04,820 --> 00:00:06,380 ‫All right. So this is me walking through the 2 00:00:06,380 --> 00:00:10,310 ‫second Compose assignment for creating a Drupal configuration. 3 00:00:10,310 --> 00:00:16,460 ‫I'm in the compose assignment 2 directory, and I'm supposed to make a Docker Compose file in here. 4 00:00:18,210 --> 00:00:27,230 ‫I'm going to switch over to Visual Studio Code. Make a new file. 5 00:00:27,500 --> 00:00:32,990 ‫I can call it whatever I want, but the easiest way to use Docker Compose is just by calling the file 6 00:00:32,990 --> 00:00:33,760 ‫docker-compose.yml. 7 00:00:33,770 --> 00:00:39,820 ‫Otherwise, I have to actually specify the file every time or set an environment variable. 8 00:00:39,890 --> 00:00:43,840 ‫That's kind of a pain. So, let's just do it like this. All right. 9 00:00:43,840 --> 00:00:46,720 ‫It said Version 2, right, 10 00:00:46,770 --> 00:00:48,570 ‫was one of the requirements. 11 00:00:49,370 --> 00:00:50,960 ‫Then I type services. 12 00:00:50,990 --> 00:00:51,740 ‫You'll notice this add-in, 13 00:00:51,750 --> 00:00:58,010 ‫by the way. This is the Docker add-on for Visual Studio Code, which is one of the great things I love 14 00:00:58,010 --> 00:00:58,640 ‫about Code. 15 00:00:58,640 --> 00:01:02,960 ‫It's a great editor. It actually has abilities to, in the background, search 16 00:01:02,970 --> 00:01:07,610 ‫Docker Hub, so you'll notice some things popping up as I type them. 17 00:01:07,610 --> 00:01:14,570 ‫If I know I've got to do Drupal, I'm just going to call this one drupal. 18 00:01:16,740 --> 00:01:22,170 ‫Then I know I have to use an image. I'm going to call it drupal because I bet you that's the name of the 19 00:01:22,170 --> 00:01:23,010 ‫image. 20 00:01:25,170 --> 00:01:28,230 ‫See how it actually pulls up there from Docker Hub? 21 00:01:28,490 --> 00:01:28,890 ‫Pretty cool. 22 00:01:31,970 --> 00:01:42,500 ‫Then I know I have to use ports to open up 8080 on my machine to... 23 00:01:42,560 --> 00:01:42,830 ‫you know what? 24 00:01:42,830 --> 00:01:52,160 ‫I don't know what port to use in the image. So let me actually go here and search for Drupal. 25 00:01:57,170 --> 00:02:00,980 ‫Let's see...what's the documentation say? 26 00:02:03,810 --> 00:02:04,940 ‫Here's an example. 27 00:02:04,950 --> 00:02:08,320 ‫It looks like it's port 80 inside the container. 28 00:02:08,370 --> 00:02:11,340 ‫If I wanted to confirm that, I could actually go inside. 29 00:02:11,560 --> 00:02:21,300 ‫I'm just going to use latest for this example. Actually go into the Dockerfile here. It looks like it's 30 00:02:21,300 --> 00:02:25,510 ‫coming from PHP Apache. There's no port command here. 31 00:02:25,740 --> 00:02:29,480 ‫If I actually want to know what the port was, I can do several things. 32 00:02:29,490 --> 00:02:38,560 ‫I could either go look up that FROM Image and see what the exposed command was in there. Or if I had 33 00:02:38,560 --> 00:02:39,760 ‫the Drupal locally, 34 00:02:44,070 --> 00:02:50,440 ‫then I did a docker image inspect drupal, 35 00:02:57,490 --> 00:02:59,380 ‫expose ports. So port 80. 36 00:02:59,430 --> 00:03:04,860 ‫I bet you that's what it's listening on, so I can just change that to 80. 37 00:03:08,650 --> 00:03:17,780 ‫Then I know for extra credit, I'm supposed to use volumes, but I'm going to come back to that. 38 00:03:17,790 --> 00:03:25,090 ‫So, the other one is going to be postgres. And then image. 39 00:03:26,520 --> 00:03:28,720 ‫Oops. No. 40 00:03:33,250 --> 00:03:35,510 ‫I don't want either one of those choices. 41 00:03:35,920 --> 00:03:36,790 ‫All right. 42 00:03:36,850 --> 00:03:40,800 ‫I don't need any ports there because it's just going to use the default when inside the network. 43 00:03:40,960 --> 00:03:44,650 ‫You'll notice you only need to use ports here when you actually need to use the -p. 44 00:03:44,650 --> 00:03:50,260 ‫Since these are both going to be in the same Docker network, I don't need to do anything for them 45 00:03:50,260 --> 00:03:53,320 ‫to connect. They're just going to work over that network. 46 00:03:53,650 --> 00:04:04,550 ‫I know the instructions said I need to set a password. 47 00:04:08,860 --> 00:04:11,010 ‫I'm just going to set it to something easy for now. 48 00:04:14,530 --> 00:04:16,110 ‫If I back up here. 49 00:04:16,450 --> 00:04:19,280 ‫I wonder what Docker says...what Drupal says about that. 50 00:04:20,450 --> 00:04:21,990 ‫I'm going to use this. 51 00:04:30,420 --> 00:04:36,580 ‫If I don't use postgres user, and it defaults to the postgres...everything defaults to postgres, so 52 00:04:37,100 --> 00:04:40,580 ‫the database defaults to that. The user defaults to that. 53 00:04:40,610 --> 00:04:41,860 ‫I just need to set the password. 54 00:04:45,160 --> 00:04:51,090 ‫I got that. I think I'm about done. 55 00:04:51,190 --> 00:04:52,680 ‫Except for the volumes. 56 00:04:56,320 --> 00:04:58,170 ‫Let's see what it says here. Volumes. 57 00:05:00,840 --> 00:05:01,340 ‫Well, look at that. 58 00:05:01,350 --> 00:05:03,270 ‫They have some examples here. 59 00:05:03,840 --> 00:05:05,490 ‫So, I could just copy these. 60 00:05:08,420 --> 00:05:12,550 ‫I'm just going to copy all four of them. 61 00:05:17,860 --> 00:05:23,040 ‫Multiple cursors is also a pretty cool thing in Visual Studio Code. 62 00:05:23,560 --> 00:05:25,010 ‫Ok. It does look good. 63 00:05:25,060 --> 00:05:29,420 ‫I'm going to save this file. Ok, let's run it and see if it works. 64 00:05:36,210 --> 00:05:38,420 ‫Great! If I'm going to use named volumes, 65 00:05:38,720 --> 00:05:40,970 ‫I've got to do the volume section. 66 00:05:42,200 --> 00:05:44,060 ‫And that's why this is a little extra credit. 67 00:05:44,080 --> 00:05:50,290 ‫So, let me actually go into the documentation for Compose 68 00:05:53,710 --> 00:05:56,950 ‫and look up how volumes are supposed to be there. 69 00:05:58,360 --> 00:06:05,590 ‫It says that I can use the named volumes without anything else in them. Like this. 70 00:06:05,630 --> 00:06:07,420 ‫So, let me try that. 71 00:06:14,860 --> 00:06:16,220 ‫Oh, look at that. 72 00:06:16,320 --> 00:06:21,310 ‫I just noticed I'm missing the d there. 73 00:06:21,510 --> 00:06:22,310 ‫All right. 74 00:06:37,400 --> 00:06:38,490 ‫Let's try again. 75 00:06:43,300 --> 00:06:46,700 ‫See how it creates the networks and the volumes for it before it starts? 76 00:06:46,700 --> 00:06:47,650 ‫That's pretty cool. 77 00:06:47,650 --> 00:06:48,230 ‫Saves us time. 78 00:06:53,290 --> 00:06:56,810 ‫All right. Looks like everything started. Let me go to localhost 8080. 79 00:06:59,590 --> 00:06:59,970 ‫All right. 80 00:06:59,980 --> 00:07:00,520 ‫There we go. 81 00:07:00,530 --> 00:07:03,180 ‫I'm going to go through to setup real quick. 82 00:07:03,180 --> 00:07:03,560 ‫Sure. 83 00:07:03,570 --> 00:07:09,490 ‫Standard. I'm using postgres. The database name is postgres. 84 00:07:09,500 --> 00:07:16,130 ‫If you weren't aware, you could actually go to Hub, and under the postgres, 85 00:07:18,690 --> 00:07:22,830 ‫there'll be documentation about how a default database works. 86 00:07:24,320 --> 00:07:29,090 ‫All the environment variables that will tell you here that if you don't specify the DB, it will actually 87 00:07:29,090 --> 00:07:30,640 ‫be postgres by default. 88 00:07:36,350 --> 00:07:45,740 ‫My password was mypasswd. Because I've done this before, I actually know that if I click here, it's going 89 00:07:45,740 --> 00:07:54,190 ‫to tell me, 'I can't connect because I'm thinking I need to talk to localhost.' And that tells me, 'Aha! I actually 90 00:07:54,240 --> 00:07:55,710 ‫have to back up here.' 91 00:07:56,150 --> 00:07:58,070 ‫Re-put in my password and under advanced, 92 00:07:58,100 --> 00:08:08,940 ‫it defaults to localhost. I need it to be the name of my service, which I just called postgres. 93 00:08:09,260 --> 00:08:11,100 ‫I can see all the errs...not the errors 94 00:08:11,120 --> 00:08:14,780 ‫but the logs in the background. It's doing stuff. 95 00:08:17,840 --> 00:08:21,710 ‫It does say errors there though, doesn't it? It's working. 96 00:08:25,370 --> 00:08:31,740 ‫Here's some basic information. 97 00:08:32,600 --> 00:08:40,280 ‫I'm just going to put in some stuff. Let's see. We'll 98 00:08:50,720 --> 00:08:51,250 ‫just call that... 99 00:08:51,260 --> 00:08:51,840 ‫All right. There we go. 100 00:08:51,940 --> 00:08:54,110 ‫Looks like I got a fully working Drupal website. 101 00:08:55,570 --> 00:09:01,660 ‫Now that I'm done, I can actually just Control c, and I want to do a cleanup. 102 00:09:02,070 --> 00:09:05,260 ‫So I want to do a down. 103 00:09:05,590 --> 00:09:09,000 ‫But there's actually an option 104 00:09:10,120 --> 00:09:11,440 ‫to remove the volumes. 105 00:09:11,460 --> 00:09:17,360 ‫Since I don't plan on using this, I'll use down -v to remove the volumes as well. Because 106 00:09:17,360 --> 00:09:22,420 ‫of course, Docker is always trying to protect volumes by default. There's no docker commands 107 00:09:23,310 --> 00:09:32,230 ‫other than docker volume remove, and prune, that will actually automatically remove volumes because it's always assuming 108 00:09:32,230 --> 00:09:34,400 ‫that you want to persist your data. 109 00:09:34,400 --> 00:09:35,220 ‫All right. 110 00:09:35,230 --> 00:09:35,880 ‫There we go.