Using Infrastructure as Code to provision a Docker container on Azure

Over the past 12 months I have spent many weeks working with customers migrating Linux based workloads to Azure. When we turn up on a customer site we often need to get OSS projects up and running on Azure as quickly as possible. The projects are usually a component of a larger solution that we need to build around as the week progresses.


  • Need to get the project up and running to enable developers to start coding,
  • Need to deploy multiple instances of the component so that they can be used in parallel,
  • Need to be able to easily re-provision a deployment that we have "broken" – i.e. Infrastructure as Code,
  • At this point in the week we are not concerned about resilience – we will often look at resilience and performance of these components as the week progresses.


Containers and Docker are now commonplace and many third party applications are now available on Docker Hub either as official or community contributed images. One of the first things I check when I hear of an OSS component is has someone already created a Docker image. Then I use the Azure Docker VM Extension to get it up and running – yes we have lots of other great solutions for running containers, such as Azure Container Service, but at this point we just need to launch the containers with minimum effort and cost.

The extension is reasonably well documented both at the project home on GitHub and on the MS documentation site,



GeoServer is an open source mapping server, . This was being used by Somerset County Council as part of their public rights of way management system. 

A quick search (I used my preferred search engine as it can do a deeper search than via Docker Hub) for an image that is well maintained (searched for the latest version) – " geoserver 2.11" returned a couple of options. I chose as the Dockerfile is published enabling us to see what has gone into the image.

The next step was to create/acquire an Azure Resource Manager template that deploys an Ubuntu VM. This is a good one to start with . By using an Azure Resource Manager template we can quickly redeploy the solution in an identical fashion again and again.

Then we need to edit the azuredeploy.json and if it doesn't already exist add child resources element under the VM properties section. This is where we will place our extension.

The Azure Docker VM extension takes a Docker compose file in JSON format. As we were only deploying a single container this is very straightforward and only needed to specify the image and ports to expose. The JSON for the extension can be seen below:

This needs pasting inside the resource element as indicated earlier. The final template can be reviewed here: .

When the template is deployed the container can be accessed on the http://vmpublicip:exposed_port. In this case the port exposed was 8080.

As the week progressed we added additional features to the template. Some of which can be found here: .

Unfortunately the extension only support Linux VMs and containers, maybe on a hack in the future we will find time to modify it so it supports Windows VMs and containers too.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.