Deploying Docker Containers with Azure Container Instances

Deploying Docker Containers with Azure Container Instances

For one of my upcoming blogposts I have been exploring options for hosting Docker containers in the cloud. Along the way I found that Azure Container Instances is a relatively straight foward, no nonsense approach if you're after rapidly hosting an image without having to deal with the orchestration or cluster creation some other PaaS solutions require.

Getting Started with ACI

Firstly, log on to Microsoft Azure here: https://portal.azure.com and click "Create a resource" in the top left hand corner.

From here click the "Containers" category and then the "Container Instances" service:

Containers

Next we need to provide some basic information about the container, as shown below:

Container_Details

The "Container image" is the base image the instance will use. In our example we are using hopsoft/graphite-statsd, which is publically hosted on Docker Hub. You can also use images from private respostories such as your own Azure Container Registry.

On the next form we can set up the configuration of the container itself:

Container_Setup

You can choose between either a Windows or a Linux container (Most of those on Docker Hub will be Linux containers) and provision how powerful the machine will be.

By default a public ip address is provided for the container, with the wizard allowing you to specific the ports the be forwarded. In this example I'm just exposing port 80 over TCP, which allows us to see the Graphite web application once it has been deployed.

On the next page we can check all the settings then deploy the container:

Container_Deploy

When you deploy the container, it will take a few minutes to spin up (Unfortunately the provisioning time on Azure is relatively slow for containers). Once finished you can open the container instance details to find the dynamic IP provided to the service:

Container_IP

Which in turn can be used to access the application on the container

Graphite_Live

Pricing of ACI

Currently in the West EU data center a 1 vCPU Linux container with 1.5GB RAM will cost you 6p an hour, which is £43.80 a month. The costs are calculated per second though, so you can happily spin down any instances when you aren't using them to save cost.

For more details on pricing, see here: https://azure.microsoft.com/en-gb/pricing/details/container-instances/

Drawbacks to ACI

The service has no orchestration built in, which means if you want to scale out your container to multiple instances you are fresh out of luck. However Microsoft do offer the Azure Container Service that provides the more advanced orchestration side.

I haven't quite figured out whether you can host the containers inside a virtual network yet. No option is present in the wizard, so how you would access a container over ports exposed only within an internal network is still a mystery.

I also found that you cannot forward both a TCP and UDP port from the same Docker container. Only 1 protocol is supported at a time across all open ports.

Image credits: Michael Gaida - Pixabay