‫All right. So this is me walking through the
‫second Compose assignment for creating a Drupal configuration.
‫I'm in the compose assignment 2 directory, and I'm supposed to make a Docker Compose file in here.
‫I'm going to switch over to Visual Studio Code. Make a new file.
‫I can call it whatever I want, but the easiest way to use Docker Compose is just by calling the file
‫docker-compose.yml.
‫Otherwise, I have to actually specify the file every time or set an environment variable.
‫That's kind of a pain. So, let's just do it like this. All right.
‫It said Version 2, right,
‫was one of the requirements.
‫Then I type services.
‫You'll notice this add-in,
‫by the way. This is the Docker add-on for Visual Studio Code, which is one of the great things I love
‫about Code.
‫It's a great editor. It actually has abilities to, in the background, search
‫Docker Hub, so you'll notice some things popping up as I type them.
‫If I know I've got to do Drupal, I'm just going to call this one drupal.
‫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
‫image.
‫See how it actually pulls up there from Docker Hub?
‫Pretty cool.
‫Then I know I have to use ports to open up 8080 on my machine to...
‫you know what?
‫I don't know what port to use in the image. So let me actually go here and search for Drupal.
‫Let's see...what's the documentation say?
‫Here's an example.
‫It looks like it's port 80 inside the container.
‫If I wanted to confirm that, I could actually go inside.
‫I'm just going to use latest for this example. Actually go into the Dockerfile here. It looks like it's
‫coming from PHP Apache. There's no port command here.
‫If I actually want to know what the port was, I can do several things.
‫I could either go look up that FROM Image and see what the exposed command was in there. Or if I had
‫the Drupal locally,
‫then I did a docker image inspect drupal,
‫expose ports. So port 80.
‫I bet you that's what it's listening on, so I can just change that to 80.
‫Then I know for extra credit, I'm supposed to use volumes, but I'm going to come back to that.
‫So, the other one is going to be postgres. And then image.
‫Oops. No.
‫I don't want either one of those choices.
‫All right.
‫I don't need any ports there because it's just going to use the default when inside the network.
‫You'll notice you only need to use ports here when you actually need to use the -p.
‫Since these are both going to be in the same Docker network, I don't need to do anything for them
‫to connect. They're just going to work over that network.
‫I know the instructions said I need to set a password.
‫I'm just going to set it to something easy for now.
‫If I back up here.
‫I wonder what Docker says...what Drupal says about that.
‫I'm going to use this.
‫If I don't use postgres user, and it defaults to the postgres...everything defaults to postgres, so
‫the database defaults to that. The user defaults to that.
‫I just need to set the password.
‫I got that. I think I'm about done.
‫Except for the volumes.
‫Let's see what it says here. Volumes.
‫Well, look at that.
‫They have some examples here.
‫So, I could just copy these.
‫I'm just going to copy all four of them.
‫Multiple cursors is also a pretty cool thing in Visual Studio Code.
‫Ok. It does look good.
‫I'm going to save this file. Ok, let's run it and see if it works.
‫Great! If I'm going to use named volumes,
‫I've got to do the volume section.
‫And that's why this is a little extra credit.
‫So, let me actually go into the documentation for Compose
‫and look up how volumes are supposed to be there.
‫It says that I can use the named volumes without anything else in them. Like this.
‫So, let me try that.
‫Oh, look at that.
‫I just noticed I'm missing the d there.
‫All right.
‫Let's try again.
‫See how it creates the networks and the volumes for it before it starts?
‫That's pretty cool.
‫Saves us time.
‫All right. Looks like everything started. Let me go to localhost 8080.
‫All right.
‫There we go.
‫I'm going to go through to setup real quick.
‫Sure.
‫Standard. I'm using postgres. The database name is postgres.
‫If you weren't aware, you could actually go to Hub, and under the postgres,
‫there'll be documentation about how a default database works.
‫All the environment variables that will tell you here that if you don't specify the DB, it will actually
‫be postgres by default.
‫My password was mypasswd. Because I've done this before, I actually know that if I click here, it's going
‫to tell me, 'I can't connect because I'm thinking I need to talk to localhost.' And that tells me, 'Aha! I actually
‫have to back up here.'
‫Re-put in my password and under advanced,
‫it defaults to localhost. I need it to be the name of my service, which I just called postgres.
‫I can see all the errs...not the errors
‫but the logs in the background. It's doing stuff.
‫It does say errors there though, doesn't it? It's working.
‫Here's some basic information.
‫I'm just going to put in some stuff. Let's see. We'll
‫just call that...
‫All right. There we go.
‫Looks like I got a fully working Drupal website.
‫Now that I'm done, I can actually just Control c, and I want to do a cleanup.
‫So I want to do a down.
‫But there's actually an option
‫to remove the volumes.
‫Since I don't plan on using this, I'll use down -v to remove the volumes as well. Because
‫of course, Docker is always trying to protect volumes by default. There's no docker commands
‫other than docker volume remove, and prune, that will actually automatically remove volumes because it's always assuming
‫that you want to persist your data.
‫All right.
‫There we go.