How to Run a Docker Container App on Microsoft Azure

Docker is not new. It was founded in 2013. And became popular with its ability to make the app portable to anywhere(AWS, Azure, GCP, other servers) and run them in the same way.

Without getting glued to a platform and without spending so much money on IaaS you can easily run application in a container. Containers will take over the world one day!

Here is a simple exercise to help you build your first docker app on Microsoft Azure.

Build and Run the Container App Locally

Step 1: Download and install docker on your local machine.

Step 2: Install Git, it is required to download project from git.

Step 3: Clone a sample project by executing the command from windows CLI: git clone https://github.com/Azure-Samples/azure-voting-app-redis.git

Step 4: Change the directory: cd azure-voting-app-redis

Step 5: Create a container image with command: docker-compose up -d

Step 6: Now you can build and test the image locally from your browser: http://localhost:8080/

Deploy the App to Microsoft Azure Container Registry

Azure Container Registry is a service that you can use to create your own private Docker registries. You can store and build docker images using container registry. Let’s do it!

Step 1: Sign up for Azure trial

Step 2: Create a Container Registry:

From the Azure portal choose “Create a resource”.

Containers > Container Registry > Create.

Provide details then, choose “Review + create”. It will a few minutes and create a Container Registry for you.

Step 3: Download and Install Azure Command Line Interface(CLI). It is required to perform Azure commands from the local machine.

Step 4: Open Windows CLI and execute command az login. It will take you to the web for authentication.

Step 5: Now, change the path to the DockerFile folder: cd C:\Users\yourusername\azure-voting-app-redis\azure-vote. Then, execute the command az acr build –file Dockerfile –registry midhundemoregistry –image demoimage . to build the docker image and push to the container registry.

Docker image that contains web app is now available for deployment to App Service.

Run the App in Microsoft Azure

We are going to use Azure App Service to run the app in container.

Step 1: Enable Admin user access.

Navigate to Access Keys and Enable Admin User

Step 2: Create a web app. Create a resource> Web App> Create.

Step 3: Provide below details and click Next: Docker >

Step 4: Choose Image Source as “Azure Container Registry”> Review + create.

Step 5: After successful deployment Go to resource.

Congrats! Now you have successfully build, deploy and run a Docker container based app on Azure!

Leave a Comment

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