How to Run a Container in Azure with Azure Container Instance

Save to My DOJO

How to Run a Container in Azure with Azure Container Instance

Hello once again everyone! I’m happy to be back for part 9 of our ongoing series on container services for MSPs!

We’ve covered quite a bit in this series thus far. We’ve talked about things like Linux containers, container networking, container persistence, and quite a bit more! All of this has been discussed through the lens of an MSP getting started with containers, and my thought process thus far has been, let’s get you up to speed with the technology, then we’ll start talking about things like support, deployment at scale, pricing, and things like that.

This is going to be a bit of a shorter segment because it fills a bit of a knowledge gap in our series thus far. We’ve talked pretty much exclusively about running containers on-premises, but I haven’t touched on how to do so in the cloud thus far. As you know if you’ve been following this series, Microsoft Azure is a supported platform for running containerized workloads. In this segment, we’ll be using Azure Container Instances to spin up a container and then access it using a public IP address.

Before we get started, let’s take a look at where the series has been thus far!

The Definitive Guide to Containers for MSPs

Part 1 – What are Containers

Part 2 – Platforms for Running Containerized Workloads

Part 3 – Introduction to Docker

Part 4 – 4 Pro Tips for Working with Docker

Part 5 – How to Run Linux Containers on Windows Server 2019

Part 6 – How to Create Persistent Docker Containers

Part 7 – Docker Container Networking – Part 1

Part 8 – How to Setup a Linux Container Host

Why Would I Run a Container in Microsoft Azure?

The main reason here is flexibility. As I’ve said many times before, Azure has a geographical reach that is quite frankly, staggering. Need a container in London? Done. Need one in China? Done. It provides capabilities that even most large enterprises would struggle to implement themselves. Additionally, it makes a great platform for testing. Sure, you can test containers on your desktop/laptop, but if you want to test things on something more akin to production infrastructure, this is a good choice.

What About Azure Kubernetes Service?

If you’ve been following the cloud news, you’ve probably heard about Azure Kubernetes Service. Many publications will tell you this is the service you should be looking at for running containers in Azure. They aren’t wrong, but whereas Azure Kubernetes Service is use more in a situation where you’ll be using the cloud for containers long-term, Azure Container Instances are nice in that you can spin up some simple containers without too much fuss.

Additionally, because we’ve not talked about Kubernetes at all *yet* in this series, Azure Kubernetes Service is still a bit out of scope at this point in time.

With that said, let’s take a look at Azure Container Instances!

How to Run a Container in Azure Container Instance

So, looking at the documentation for this will make it seem quite complex, but once you step through the process, you’ll see that it’s fairly simple.

NOTE: This How to assumes you have an Azure account set up and ready for use. If you still need one you can sign up for a free account here.

To start the process, log in to the Azure Portal and Click “+ Create a Resource” in the top left. Then, select the Containers category and then click on Containers Instances in the right hand column as shown in Figure 1 below.

containers in Azure

  Figure 1: Choosing Container Instances in the Create a Resources Wizard

After selecting Azure Container Instances, you’ll be taken to the Create Container Instances Wizard. It’s fairly straight forward, but there are a number of pieces of criteria to step through. Start by Naming your container and the point to the URI or Docker Hub Tag of the Image we want to use. For example, if you’ve been following my series, you know that in the Syrewicze household, Minecraft is a “Critical Business Workload”. All joking aside though, I do find it useful for showing how containers can provide accessible services that are visible in a demo scenario. So we’ll be using the itzg/Minecraft-Server image in the Docker Hub for this example.

After that you select the subscription you’d like to use, and a resource group and location to host the workload. If you need a little bit more information on how resource groups work in Azure, take a look at our article on Azure Resource Manager here.

Once you’ve made these selections, your screen should look like figure 2 below.

creating a container instance

  Figure 2: Container Basics

On the next screen, we’ll define a few more settings to really control how this container behaves.

  1. We have to define an OS type. In our case, the source container image we’re using is a Linux-based container image.
  2. Then we have to define the number of CPU cores, and the amount of memory, which we’ll leave at the default.
  3. In order to access the workload, we’ll give it a public IP as we don’t have an Azure vNet setup for remote access and we’ll provide a DNS name label so it’s a bit easier to access (more on this later)
  4. Minecraft uses the TCP port 25565 so we’ll set that as the port in use
  5. Leaving the Restart Policy to Always, will ensure that if this container stops for some reason, it will be powered back on.
  6. Environment variables then need to be set. These are defined in the manner of “Key”:”Value”. Which is a little different than what we’ve had to do on-prem thus far. To keep things simple, we’re going to do the minimum of accepting the EULA, but your own container could use a number of different variables if needed.

Once done, your settings should look like the below!

Azure container configuration

  Figure 3: Container Configuration

At this point simply click OK to view the summary, and then again to deploy!

After a few minutes, the container will boot, and I can retrieve the full DNS name, but looking at the container summary screen below

  Figure 4: Container Instance Dashboard

Once I have that, I can open Minecraft and put the server info in and play till my heart’s content!

  Figure 5: Minecraft Server Running in Azure Container Instances

Wrap-Up

While Minecraft likely isn’t a critical workload for your business, you can kind of get the idea of how easy it is to spin up a container in Azure. No matter the workload, Azure provides a powerful platform for hosting containerized workloads, and we’ll be talking about this much more in the future once we start talking about Kubernetes as part of this series.

What about you? Do you see this being useful for your organization and customers? Do you have any questions about this process? Let us know in the comments below!

Altaro O365 Backup for MSPs
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

Leave a comment

Your email address will not be published. Required fields are marked *