Check out a free preview of the full Full Stack for Front-Ends Part 2 course:
The "Containers" Lesson is part of the full, Full Stack for Front-Ends Part 2 course featured in this preview video. Here's what you'd learn in this lesson:

Jem introduces containers, the benefits of containers, and some examples of how they are used.

Get Unlimited Access Now

Transcript from the "Containers" Lesson

[00:00:00]
>> Jem Young: All right, so that was part six. That wasn't that bad. It's just pure lecture, we installed the database. Last part, talking about containers, orchestration, and automating our deployments. So what's a container? Anybody? You've probably heard the phrase, it's kind of hip. Like cloud computing was using that phrase a couple years ago.

[00:00:20] Containers.
>> Speaker 2: It's kind of like a hypervisor, but it loves at a different level I think, for like a virtual machine.
>> Jem Young: Yeah, hypervisor, virtual machines, big words, I like it. You're right, a container is just the application, rather than an entire operating system. So let's talk a little bit more, because it's important you leave the room, and you might not implement it, but you understand when someone says containers or hypervisor that you know what they are talking about, cuz you're a full stack engineer now.

[00:00:50] You made it through part two, just about, it's the last part. So from the first section, we remember that a VPS, virtual private server, is just one dedicated server and we just have little chunks. So my digital server, it's just, it's a little chunk of a larger server.

[00:01:06] It's not a little box running somewhere in the room. It's just part of a larger server. That's what a VPS does, it breaks it into little chunks, and remember that VPS, you put them all together equals the cloud. I still see people like airport ads, I think targeted people that don't know, they're like, do you know the cloud?

[00:01:24] I'm like, yeah, I know the cloud. I know a few [INAUDIBLE], jeez, I'm insulted really. But that's a VPS. A container is, it's just the application run on VPS. So take your VPS, segment it even more for just the applications that are running, that's a container, just one application.

[00:01:44] So right now our server that's running right now, we have nginx which is an application, we have mysql, we have node running. These are all separate applications of one large server. With the container I would just run node in some container, I'd run mysql in some container, I'd run nginx in the some container.

[00:02:02] Why would I do that? What's kind of the efficiency you think we'd get out of that? Anybody, I mean, I have bullet points ready. [LAUGH]
>> Speaker 3: That you're only paying for what you're using?
>> Jem Young: No, not really, but that's a good guess. The benefit of a container versus a virtual machine, which is what we are running on now, which is just a fake server.

[00:02:26] It looks like it's own machine, but it's really a part of a larger machine, is that we don't have to install an operating system. There is no overhead for things like that. We can share all of our resources, but only the ones that need to be shared. So, if my notes ever goes haywire, it starts writing log files everywhere, it won't affect the other operations on the server versus now, if my node server goes haywire and starts messing up the caches for everybody else, it's gonna take down the entire server.

[00:02:52] That's some of the benefits of a container versus an entire vps, which is what we're running now. The second benefit is fast deployment. So rather than reinstantiating an entire new server every single time we wanna make a new node app, we just pick container for that, and deploy that out to a server that's already running.

[00:03:08] When we wanna update that, we just deploy that out too the same way. Containers, it's nuance that I don't think before this course you would have understood the nuance of it, but now you do a little bit more.
>> Speaker 4: So is it the concept, or just the concept, or it's-

[00:03:25]
>> Jem Young: No, it's a real thing. No it's not a, that's a good question. There are things that are concepts of how we do server deployments. Things like that, like containerization, but these are actual different processes that run. So you mentioned hypervisor. A hypervisor is essentially virtual machine that access, I'm gonna run I'm gonna run one instance of the Ubuntu, I'm gonna run a instance all in one server, but hypervisor manages that.

[00:03:55] So it manages the scheduling of the CPU, so it's saying, you get a chunk, you get a chunk, you get a chunk. That's what a hypervisor does, and it runs a virtual machine. Instead of that, we just have one machine and the container manages that for you. It's nuance, but I have some diagrams that'll hopefully make it a little bit more clear.

[00:04:13] So, why, again, why do we wanna container? Because this is an example of the Netflix infrastructure. The names are different obviously, but this is a real tool we use called Visceral, and it's a real time traffic map about what's happening on the Netflix cluster. We have thousands, and thousands, and thousands, and thousands, and thousands of servers.

[00:04:33] It's unimaginable. I forget the exact count, but there's a lot. I forget how many, so I work in, would be probably this, something like this. I work on the node app which is where all the request eventually hit. There are some layers before that, but I work on one small section.

[00:04:51] There's all these other microservices running at Netflix. So why is it that we use containers over a bunch of virtual machines? Well, because it's faster, because we have all these things that we need to update, we need to take down. We don't want it to impact other people's' workload, but we also don't wanna bring up new servers, cuz as we've all known, bringing up a new server, it's not necessarily that fast.

[00:05:17] It can be slow, there can be issues, especially when you bring it up, 10,000 of them at the same time, or something like that to process videos. Why would we do that? We can have servers running and then swap out the containers as needed, and they handle the resource management for us.

[00:05:31] I have another diagram. Even better, cuz I have many diagrams, cuz containers are a little bit tricky. So this is a virtual machine. This is what we're running right now on our web server. We have our apps, so we have Node, we have NGINX, MySQL, Postgres, things like that.

[00:05:46] We have all these apps running. They interact with the libraries, the applications, that interact with the kernel. So instead of that, we have a container on this side. Container has its own libraries that it needs. So NGINX needs to know about like our socket library, things like that.

[00:06:03] That's all self-contained in its own container, and then that all interacts with the kernel instead of going through all these separate libraries that are shared by everybody. How to make sense of it, these are the things that only make sense at scale. You wouldn't have to do it for, I don't know, ten servers.

[00:06:19] You'd probably get ahead of yourself. But when you talk about scaling, containers are definitely the way that most companies are going now. It's just more efficient. So, the big word you hear in containers is Docker. Everybody heard of Docker at some point? Yeah, Docker is a container management tool essentially.

[00:06:37] You can create containers to ploy them out, it helps manage the memory, the bandwidth, things like that, make sure the libraries are self-incapsulated, that's what Docker does. We're not gonna go through that today, cuz that's a whole other course. But, just so you know when someone's like, yeah, use Docker, and things like that, you know exactly what they're talking about at this point.

[00:06:56] A Docker setup looks something like this, and there's a link at the bottom if you wanted to create a Docker container, install Postgres. It's a bit tedious, it's a bit kind of nuanced, but look, it's just running, I won't say shell commands, but it looks kind of like shell commands, we're just running a bunch of scripts like that.

[00:07:15] That's what a Docker setup does, but the benefit is, once you make a container once, so you make the script to create a Docker instance, you can just create 20 of them at once. So rather than us going through the same steps we did over and over and over again, we can just do it once, and it's always gonna run the same way every single time.

[00:07:33] That's pretty cool. All right? Good so far, yes?
>> Speaker 5: So it's not that Docker is a language analagous to Bash, right, it's that it's a program or something like a kernel almost that takes in Bash and then processes that or takes in a shell right?
>> Jem Young: Not necessarily shell language.

[00:07:59] This is just one instance of how to create Docker commands. It's his own, dockers are container manager. So it's a way of bringing up containers. Let me step back. So we have virtual machine. We all know what a virtual machine is now, it's that little chunk of a server that we're running.

[00:08:20] Docker is essentially a virtual machine, nobody's assuming it's not a virtual machine, but think of it like that, but instead of machines it brings up containers, and it manages all the containers just like a virtual machine does. Yeah, it's yeah, like I said, it's a little tricky, but I just wanted everybody to get a look at it so we understand what a container are, what a Docker does.