Over the past few years I have worked with Docker and Microsoft Azure and I want to share my experience in combination with Microsoft Azure. Suppose you have a Virtual Machine with a service or tool on it. By hand, you can very easily create one and configure the proper installation of it. If you want to start using more power, then with some time you can turn it into two, three, four or five Virtual Machines. But then your conscience begins to wring. How do I handle updates? Can I temporarily use more or fewer machines? How do I automate this?

This is the point where Docker starts to come in handy. You create one container that contains the entire Virtual Machine installation and configuration, and you use it everywhere. On the developer’s laptop, on the tester’s test environment and in the automated build & release pipeline. After all, once you have a Docker image, you can deploy it anywhere and as much as you want. And the great thing is that the developer and production look at the exact same thing.


You create a Docker container with a Dockerfile. A Dockerfile describes the “system” your application runs in. Do you have Windows or Linux? What is the working directory? What do you need to configure on the system?

With a .Net Console Application, you can easily upgrade to a Docker container with Visual Studio. In ‘Solution Explorer,’ open your project’s context menu. Choose ‘Add,’ then ‘Container Orchestrator Support,’ then ‘Docker Compose.’ This automatically adds a Dockerfile to your project.

Example Dockerfile:


Described here is a Windows system that copies the app .dlls and .exe to C:app on the system.

A ‘docker-compose.yml’ is also added to the project. This ensures that the Dockerfile is built when you build the project.

To build a Docker container, you must install Docker Desktop on your PC. This provides the right tools to work with Docker locally. Part of this is the Docker CLI (Command Line Interface) that lets you control all the Docker work yourself. Everything in Docker can be accessed through the ‘docker’ command.

You can call building the Docker container in a Powershell window with ‘docker build .’ in the folder where your Docker file is located.

Visual Studio integrates smoothly with the Docker CLI. Just build the project in the Release configuration in Visual Studio. In the build output, you see the Docker build come up. Visual Studio calls the ‘docker build .’ underwater here. command.

Output from the Docker build in Visual Studio:


You can run the new Docker app locally with ‘docker run –rm <imageid>’, getting the imageid from the Docker build output. This causes the Docker container to load locally and start the default app in that container. In the Dockerfile, you will see at ‘entrypoint’ that the new app is automatically started.


Now that you have the application running in a Docker container, you can easily run the container in the cloud. A Docker container is a generic “exchange format” that works in Google Cloud, Amazon AWS or Microsoft Azure. Let me zoom in on the capabilities within Microsoft Azure.

Entry for Docker in Azure is through an Azure Container Registry. This is a kind of private DockerHub hosted in Azure from which you can integrate the container into Azure services. The Azure Container Registry works like a version control system, and you create it yourself in your Azure Subscription.

You upload the Docker container to an Azure Container Registry as follows. First, you need to link the local Docker container to the Azure Container Registry. This link is also called a “tag” in Docker.


After the “tag,” the Docker container is ready to upload. Similar to a version control system for program code, this process is called “push.


You can now find the Docker container in the Azure Container Registry in the Azure portal under “repositories. Now the Docker container is discoverable in the Azure cloud and you can start deploying it via an Azure service.

You can run a Docker container in a compute cluster in Kubernetes or Azure Batch. Azure Functions have support to run Linux containers. And finally, you also have support in App Service to host your website as a container. But a much more entry-level variant is Azure Container Instances. Here you can run a Docker container on a ready-to-run Virtual Machine, so to speak. It is the ideal stepping stone to bring the Docker container to the cloud.

The Azure Container Instance is especially useful if you don’t need scalability, just one instance of your application. As a next step, you could use Azure Batch if you do need scalability. You have even more control and capabilities with Kubernetes in which you can define infrastructure in addition to scalability. In this article, I’ll stick to Azure Container Instances.

You can do all the configuration in the Azure portal. From the Azure Container Registry repository, you can right-click directly on the Docker container and choose run instance. You can also create a new resource and choose the Azure Container Instance resource. In both cases, you are referring to the location of your Docker container in the Azure Container Registry. You choose Windows or Linux, CPU and memory and you’re all set.

An Azure Container Instance deployment is still quite feature-rich in the Azure portal. First, you can view the events. Here you can see when your Instance started and stopped.

Azure container instance deployment in Azure Portal

You can view the properties and environment variables at properties.


Eigenschappen environment aanpassen in Azure portal


You can inspect the logs of the Azure Container Instance.

Logs van Azure container instance inspecteren

Finally, you can even login to that Azure Container Instance through the Azure portal and “walk around” on that machine as if it were an ssh connection to a VM. It is not a full-fledged RDP session, but as with servers the more common command prompt.

Inloggen Azure container Instance via Azure portal

main conclusions

Bart Kooijmans senior software engineer

Sparring with bart about working azure?