What are Azure Container Instances and how do I use them?

Due to the growing popularity and utility of containers, Microsoft Azure is now offering this emerging VM-alternative as a “top-level resource in Azure.” Azure Container Instances is now publicly available and generates both Linux and Windows-based containers. Here we’ll explore the nature of containers, a relatively recent innovation that can help you develop, deploy, manage, move, and scale your applications. Then we’ll walk through a recent tutorial that helps you get started with Azure Container Instances. Because many Azure users accumulate large collections of containers, we’ll also take a good look at container orchestrators, which leverage automated tasks to run and manage a container collection. We’ll focus on Kubernetes, a popular open-source container orchestrator with strong ties to Azure Container Instances. Kubernetes on Azure is clearly Azure’s most straightforward container-orchestration solution. However, Azure’s connector gives you the freedom to work with other orchestrators, such as Swarm, as you explore ways to leverage the power of your container collection.

Understanding containers

A relatively recent innovation, containers can help you develop, deploy, manage, move, and scale your applications. Accordingly, containers and container orchestrators have enjoyed tremendous growth in recent years. However, in order to leverage containers, it’s important to understand what they are and how they work.

An intuitive description

At an intuitive level, you can think of a container as a computational package, or briefcase, that includes everything you need to run a particular app or software suite in nearly any environment. By keeping your apps independent of other processes on a given platform, containers ensure that your apps will always launch and run the same way, whether in a sandbox or staging environment, on-premises or in the cloud.

A technical description

According to Ben Corrie of VMware Cloud-Native, there is no universally accepted definition of a container. Nonetheless, Corrie prefers “the runtime definition,” which essentially treats a container as “a sandbox for a process.” Corries argues that containers, as independent sandboxes, are useful because we often have good reasons to isolate one or more processes running on the same OS. A container makes this possible. Generally, a given container will run only one primary process, such as a sophisticated app, with a number of auxiliary secondary processes supporting it.

Distinguishing containers from VMs

Although containers and VMs both give you a way to run any number of complete, independent applications on a single platform, they achieve this accomplishment in very different ways. While each VM must run its own OS, containers run on the OS provided by the platform at hand. This makes containers leaner and more portable than VMs. Another advantage is that you can run containers within containers without the severe performance degradation you often encounter when trying to run VMs within VMs.

The Quickstart experience

The only necessary prerequisite for getting started with Azure Container Instances is to create an Azure resource group. If you already have one that you can use to deploy a container instance, then you can jump right in.

Azure CLI

The Azure team encourages users to use Azure CLI to create and manage Azure Container Instances. Azure CLI, also known as Azure Cloud Shell, is a command-line utility that makes it easy to perform common Azure functions. To open Azure CLI for the first time, simply click on the “>_” icon found in the top navigation bar of the Azure portal. Of course, you can also install Azure CLI locally.

RELATED  Keep Your Business Safe with Azure Security Services

Creating a basic container

Once you’ve opened Azure CLI, you can use it to give your container a name, image, resource group and public IP address. To get started, you might want to follow the tutorial given by Sean McKenna, Program Management Director at Azure. To create an example Linux container, McKenna enters the following at the command line prompt, where he uses acidemo in place of [RESOURCE GROUP].

 az container create --name helloworld --image microsoft/aci-helloworld --ip-address public -g [RESOURCE GROUP]

You can follow along with the tutorial by using one of your own resource groups in the above formula. Note that McKenna chose to create a Linux-based container for his tutorial. If you’d prefer to create a Windows container instance, then you will need to “provide an OS type flag, and just say it’s Windows.” This will let Azure “know the base image to run it on.”

Once you’ve entered the above with necessary adjustments, press Enter and watch as Azure spins up the corresponding container instance immediately.

Checking the status

At the next prompt, you can check on the status of your new container instance by using the following formula:

az container show --name helloworld -g [RESOURCE GROUP]

Press Enter to confirm that your container instance is in a “succeeded state.” Next, visit the public IP address generated. You should see a simple page that reads “Welcome to Azure Container Instances.”

Overriding the defaults

In McKenna’s tutorial, the system creates a public IP address and uses the standard defaults: port 80, a single-core CPU and 1.5 Gigs of memory. However, you can easily override these defaults. For example, if you want to create a container instance with 2 cores and 4 Gigs, you can use the following approach at the initial prompt:

 az container create --name helloworld --image microsoft/aci-helloworld --cpu 2 --memory 4 --ip-address public -g [RESOURCE GROUP]

Listing your containers

You may want to repeat the process above, perhaps with slight variations, in order to get a good sense of how to handle a collection of containers. Once you have several containers created, you can easily list out your containers in a given resource group in tables. Use the following approach:

az container list -g [RESOURCE GROUP] -o table

Azure CLI will respond with a tabled list including the name, state, image, IP address/port, CPU/memory, OS type and region for each of your containers.

Container orchestrators

Azure Container Instances is designed to work smoothly with a container orchestrator, such as Kubernetes or Docker Swarm. A container orchestrator is a toolset that leverages automated tasks to run, manage and otherwise orchestrate a collection of containers.

Kubernetes

The Azure team published a discussion and tutorial on how to use Kubernetes, in particular, to get the most out of your container instances. Kubernetes is a widely used open-source container orchestrator. Although “Kubernetes open source projects” have remained independent, “Microsoft is a significant contributor,” guiding them to work well with Azure. In fact, one of the founders of the Kubernetes project, Brendan Burns, is also the director of Azure Container Instances. According to Burns, one of the strongest selling points of containers and container orchestrators is that they share many of the virtues of VMs while reducing or even eliminating your dependence on VMs. This freedom from VMs, in turn, makes it easier to deploy and leverage a large collection of containers that you can manage with an orchestrator like Kubernetes.

RELATED  Leveraging the High Scalability of the Azure Blog Storage Service

Kubernetes on Azure

Kubernetes on Azure is a powerful tool for managing your containers in Azure. The Azure team has the “Azure Container Service Engine (acs-engine)” up on GitHub for anyone to view and contribute to.

Linking Kubernetes

To link Kubernetes to Container Instances, you need to use a connector, which you can run easily through Azure CLI. The connector will give Kubernetes access to your containers. More importantly, as Brendan Burns explains, the connector will give you the opportunity to use Kubernetes as a kind of “giant virtual machine that you get to run all your containers on.”

Other orchestrators

Thanks to Kubernetes on Azure and the connector, Kubernetes is the most straightforward container-orchestration solution available on Azure. However, it’s important to remember that Azure’s connector is fully compatible with other container orchestrators, such as DC/OS or Swarm.

The power of containers

As outlined above, containers are a relatively recent innovation that can help you develop, deploy, move, manage and finally scale your applications. At an intuitive level, you can think of a container as a lean computational briefcase that helps you carry and run your apps in any environment. On a more technical level, we might defer to Ben Corrie’s “runtime definition,” which treats a container as “a sandbox for a process.” Either way, it’s important to remember to distinguish a container from a VM, which must run its own OS.

As Sean McKenna’s tutorial clearly illustrates, getting started with Container Instances is entirely straightforward. If you already have a resource group, you can simply click on the “>_” icon in the Azure portal top navigation bar to open Azure CLI (aka Azure Cloud Shell). Then follow the formulas above to create any number of basic Linux or Windows containers; confirm that they’re running; override the defaults, and list your containers along with their key specs.

Because large collections of containers have become such a useful expedient for technologists, it also makes good sense to acquaint yourself with container orchestrators, which leverage automated tasks to run and manage container collections. You may want to start with Kubernetes, a popular, open-source orchestrator with strong ties to Azure Container Instances. Indeed, Kubernetes on Azure serves as a ready-made solution that was built to bridge the two systems seamlessly. However, if you would prefer to use another popular orchestrator, such as Swarm, to leverage your collection, the connector provided by Azure will still pave the way.

To learn more about Azure services changing the cloud computing landscape in 2018, our Azure Consulting services or Azure Support services, contact us.

About Paul William

Throughout my career, I have been a contributor for several tech-companies as a technical writer. I have also written business plans, product development roadmaps and dozens of online newsletters. In terms of my writing strengths, my strongest categories are IT, startups, science and real estate. I bring a wealth of knowledge around technology, the cloud and IT and I enjoy writing about these topics.