Cloud Infrastructure: Startup to Scale

Running the Docker Container

Erik Reinert
TheAltF4Stream
Cloud Infrastructure: Startup to Scale

Lesson Description

The "Running the Docker Container" Lesson is part of the full, Cloud Infrastructure: Startup to Scale course featured in this preview video. Here's what you'd learn in this lesson:

Erik walks through the process of running a Docker container for local development. The docker_compose.yml file is discussed, and the container is run. He also compares Docker Desktop to other solutions like Orb Stack.

Preview
Close

Transcript from the "Running the Docker Container" Lesson

[00:00:00]
>> Erik Reinert: Okay, cool. So we have sourced our ENv, we know that we have all of our values. So now what we're going to do is we're just going to do Docker compose up, detach. So I'm gonna actually run a container now. Now we haven't even looked at the file, so we're just going to blindly take the steps that the doc.

[00:00:24]
The readme said and just hope that it works, right? So you should see something more like this. You'll see it. Start pulling the image and then run it. What is Orb Stack? Good question. So I'm a little bougie. It's the easiest way to put it. I use a Mac in my own personal development experience.

[00:00:50]
I really don't like having to deal with stuff. And I hated Docker Desktop I hated it, itwas a terrible experience. I didn't have a really good experience just dealing with it. Whatever. A while ago I heard about something called Orb Stack. It's a Mac only tool, from what I know.

[00:01:10]
I don't know if it's available on Linux. It might be, but it's basically an alternative to Docker Desktop. The thing that makes it really nice though is that you can even manage VMs with it. This was something I always wanted Docker Desktop to do. I always wanted Docker Desktop to be able to make it so I could create VMs as well.

[00:01:29]
But they didn't. The idea here is I can run containers. You'll see. Here is my workshop postgres container. I have this nice UI, I can run kubernetes as well. Now granted you can do that with Docker Desktop, but this is, in my opinion, nicer. The next thing it tells us to do is if we go back to this readme, right?

[00:01:49]
It says, okay, M created credentials and then go, run main, go. So if we do go, run main, go. Okay, cool. Does that do that for you guys? I got a password authentication failed for Postgres. Okay, did you guys get that too? I did, you got that as well.

[00:02:15]
So I did not realize this. I apologize. Orb Stack, I guess is their networking works a little bit more like integrated, I guess. So in the Docker compose here, it says network mode. We just did this to make our lives easier. But what I want you to do really quickly is just change this to this right, right here.

[00:02:41]
So get rid of the host and simply change that. What's funny is you just went through something that is very common in software development, which is I got code and now it's not working on my machine. If you change that, and then you just do Docker here, I'll just do down like this and then bring it back up, then do go run.

[00:03:08]
It should still work. You can see that for me, it worked in both scenarios because of just how Docker Orb Stack works for me. But the results, again, even though it's slightly different, it should be the same result. So try going to that URL. Do you get this?

[00:03:27]
Yeah. So this is another fun part about deploying applications is you may have it running, but it doesn't mean that it's working. And so this is a scenario where this is why I did it this way was because you're absolutely right. We didn't run any schema data migrate.

[00:03:45]
We did nothing, we just went up and worked. So this kind of goes back to that whole readme SQL document and everything like that. If the user didn't realize they had to do that or whatever, then they would easily fall into this. And then you'd be hearing somebody messaging Slack, why is this not working on my computer?

[00:04:02]
So, yeah, it would be cool if in the future we can just do up and then maybe something else so that we know it gets seeded and then run so that we know that we're all good to go. So I'm going to stop running the application really quickly.

[00:04:21]
The next thing I'm going to do is I'm going to go back to the document because I realize, okay, I got to run some stuff. Did you just do Docker Composer down, or you left the containers running? Yeah, we wanna keep the containers running in the background. And the reason for that, and this is what I want you to try as well, is because in the setup, you'll notice that there's a command right here.

[00:04:43]
Docker, compose, exec, postgres, psql U, blah, blah, blah right This makes it so that we can actually connect to the instance and run some stuff. So I'm going to open up a new window or a new tab and. And then I'm just gonna run that here, actually source, and then I'm just gonna run that command.

[00:05:00]
So make sure you source your M and then run that command. Now if you run that command and you're. Again, I'm very curious to see what happens for you. You should get this. The next thing we want to do really is just copy this whole block of code here, all of the SQL from the first SQL all the way down to the last line, then just paste that bad boy in like that Once you copy that and then you hit exit, we now should be able to go back, do go, run again and then if I refresh, yay, my application loads up, I'm logged in.

[00:05:41]
So that's the first thing. The next thing we want to do is actually try the login process. So do me a favor, click on, get started, go through that and there you go. Now I am logged in with my profile. Cool. Awesome. Then if I click logout, I should go back to that.

[00:06:04]
So what do we know? We know that we set up a database. We know that we gave it credentials or, sorry, we gave it SQL. We know that we have our OAuth client set up as long as we expose the environment variables the right way. And we know that if we run the application with all of that stuff, precursor set up, it works.

[00:06:27]
Cool. If we were in this scenario, we would then say, okay, I now know how this app works, I know how it runs and I know what I need to set it up again. The reason why we went through this is that this is part of that understanding of you can't just take an application and do nothing with it.

[00:06:48]
You really have to get comfortable with it a little bit to be able to maintain it and understand what are its parameters and all of that. Cool, awesome. This works and we are moving forward. Let me see what we've got next. Now, if you want to, just to be sure, and I would even recommend this is use it a little bit.

[00:07:12]
So I'm going to go in here, let me start running the application again. So I'm going to go in here, I'm going to go back in, log back in again, then I'm just going to share something. Hello World. Share, update. Okay, cool. So database is even working. If I click on this, this is my comment.

[00:07:46]
Cool. Okay, so again, not only did we test login, we actually tried making sure that functionality is working. I can update, I can add comments, we're in a good spot. The database, everything is working and we have successfully ran the application.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now