Containers

Natasha Ong
This is some text inside of a div block.
4 min read

In a nutshell:

While virtual machines are an excellent way to save the money needed to buy physical hardware, they're still limited to a single operating system per virtual machine.
Containers are like lightweight, agile cousins of Virtual Machines, sharing the host OS, making them faster and more flexible.
Azure offers container services, including Azure Container Instances, Container Apps, and Azure Kubernetes Service, each tailored to different use cases for running and managing containers.

Virtual Machines have been an absolute game changer in the world of cloud computing - but there are other compute services out there!

Different compute services fit different user needs. Let's start by talking about Azure containers – the Virtual Machine's cool cousin that's lighter and more agile (i.e. more flexible and adaptable to change).

Note that this unit has some pretty techy words, but we'll be explaining them one by one. That's why we're expecting this to take 20 minutes to read, even though this pieces is not much longer than the rest!

What are Containers? How are they different from VMs?

Virtual Machines (VMs) are versatile, but they can only run one operating system at a time.

You'll need to run multiple VMs at the same time for apps that require different operating systems, which can get pretty clunky. Also, VMs take their sweet time to start up - every time you run a VM, you need to wait for its operating system to get ready too (this takes a few minutes each time, which really adds up).

Containers are different. They don't include a full operating system; they share the host machine's* operating system. When you create a container, you are bundling your app along with just the required dependencies** it needs to run correctly.

*A host machine, often just called a "host," is like the main computer that manages and controls other computers or devices that the virtual machines/containers are connected to. It's like the central hub of a group of workers that keeps them working together.

**Dependencies are additional software that an app relies on to function correctly. Think of them as the backstage staff in a play. They're not the main stars (the app) but are essential to make everything run smoothly. For example, a delivery app like UberEats would rely on location services (like Google Maps) to display a map. This means Google Maps is a dependency for Uber Eats!

This is called containerisation. Another way to think about containerisation is having a potluck (the container) where everyone makes their dish (app) with the required ingredients (dependencies), but they all use the same shared kitchen (host OS) for cooking.

When these elements are packaged together in a container, the container becomes a single, standalone entity that can be easily moved and run on different operating systems without the need for additional setup or adjustments. This is a big difference from virtual machines. With EC2, you have to set up the operating system and install all of the app's dependencies in every sing instance.

So, EC2 instances virtualise the whole computer, while containers virtualise just the operating system. There is no need to wait for a whole operating system to start up (which you'd do with EC2 instances), and containers use much far fewer resources. That's why containers are considered efficient and 'lightweight'!

Have you ever tried to share something with a friend who uses a different brand of computer to you? Maybe you're a Windows person and you're trying to share a Word document with someone who uses a Mac (or vice versa). It's the worst! The formating ends up all wrong, it takes ages to load...sometimes your friend even has to download Word from scratch and set it up! Yuck! Containers help to solve this sort of problem, but instead of a Word doc, it can be entire applications, code bases, or databases! Imagine how much more complicated that can get. Best to use a container so we know everyone is running the same app with none of that set-up issue.

How people use containers

Containers are perfect for creating solutions with a microservice architecture (a microservice architecture breaks up a big app into smaller, independent pieces). For example, you can separate your website into a front end (the pretty page you see when you load the website), a back end (the behind the scenes code that makes everything run smoothly), and a storage container (where all the website's videos and photos get stored).

This separation lets you manage, scale, and update each part independently. Say your website's back end is getting swamped, but the front end and storage are chill. With containers, you can scale up the back end without messing with the rest. And if you need to change the storage or tweak the front end, it won't disrupt the other parts.

Azure's container services

Azure provides three container-related services to help us create, run and manage containers easily.

Azure Container Instances

Azure Container Instances (ACI) are the fastest way to run containers in Azure. No virtual machines to manage here! Just upload your containers, and the service handles the rest.

ACI are the perfect pick for any short-term projects - for example, if you just want to quickly test a specific part of an application without complex setup, and you'll delete the containers right afterwards.

Azure Container Apps

Container Apps are similar to Container Instances, but with extra perks. They remove container management hassles by adding in in load balancing and scaling features. Load balancing is a feature that makes sure everyone visiting your app gets a fast experience without waiting too long; scaling automatically adjusts how many containers you're running based on how much is needed.

In comparison, ACI does not provide either load balancing or scaling. This makes Azure Container Apps much better for more long-running services (e.g. a website), while ACI is used for more straightforward tasks (e.g. running tests on a new feature you're building, before adding it to your website).

You'll be doing some hands on Container Apps work very soon... here's a sneak peek!

Azure Kubernetes Service

Azure Kubernetes Service (AKS) is like the conductor of a container orchestra.

A key phrase that gets used with AKS is fleet management, which means:

  • Making sure your entire collection of apps are running smoothly
  • Anything that need maintenance gets fixed
  • Scaling the number of containers if needed.  

When you have a complex application with lots of containers to deal with, choose AKS to keep things efficient.

And that's a wrap on containers!

Phew you made it to the end - nice work.

As a summary, here are some key facts about containers:

  • You don't have to worry about the operating system for each container. This is the key difference compared to VMs!
  • They're great for when you want to run multiple instances of an app on a single host.
  • Containers are designed to allow you to respond to changes on demand. With containers, you can quickly restart if there's a crash or hardware interruption.
  • Docker is a popular technology used for creating and managing containers, and Azure's services support Docker too.
  • Containers don't sacrifice isolation - so even though you're running containers on one computer, they stay separate and don't mess with each other.