Docker containers are ingenious tiny devices. They are essentially self-contained programs that may operate on any operating system.

I will show how to use a Docker Container to execute your application on Microsoft Azure in this blog. The Azure Portal (a web-based application) and the Azure Command-line are used to demonstrating each step.

You can now run it on any Windows, Linux, or macOS system without having to install anything since you have put everything you need to execute it within a Docker container.

Registry for Docker Containers

The first step is to publish our Docker Image to the Azure Cloud. We may upload the image to a public repository like DockerHub, where it will be picked up by others using Docker.

However, when dealing with business applications, it is best to keep the image in a secure location where only authorized users may see it.

The Azure Container Registry is a built-in feature of the Azure platform that can be used for this. Docker Registry allows you to run a private Registry for your images, which the Docker Container you start later can pick up.

Container registry using Azure Portal

The Azure portal allows you to build a registry, but connecting to it and pushing photos there is much easier with the Azure CLI.

There is a new resource called “Container Registry,” or ACR, that you can access through the portal when using it. The following values must be specified:

Registry name, As a result, this name will appear as part of your Docker Registry’s private URL. Your first pick might not be available because it needs to be unique over the world.

Resource group, resources that make sense together. It makes it simple to locate a specific resource or to purge all resources in go with a single command (like all the resources you create when you follow the examples in this blog)

SKU defines the size of the registry. Generally, the ordinary selection will suffice.

Container registry using Azure CLI

The following commands are used to create a container registry Using Azure CLI

az group create –name myresourcegGroup –loctaion eastus

By using this command, you can organize your Azure resources into logical groups. After testing is complete, you may quickly discover and delete all resources associated with this demo.

Check out this list to see if there is one near you. https://azure.microsoft.com/en-us/global-infrastructure/locations/ and the output of

az account list-location

In order to construct the Registry, we first need to create the Resource Group, or, if you like, use one of the Resource Groups you previously built.

az acr create –resource-group myResourceGroup –name psacr001 –sku standard

Upload an image to the registry

We are ready to upload to Azure Infrastructure now that we have a Docker Registry for our Docker images.

Because we have created a private Repository, we will need to log in to use it. We can accomplish this without Docker CLI, but the Azure CLI offers a useful command that will do it for us depending on the credentials we have provided for this CLI.

az acr login –name psacr001

Authentication has been configured in our Docker CLI, and we are ready to create the Image and send it to our Registry.

It is possible to push an image that has already been made public by giving it the appropriate tag. If not, you can create one and provide the required tag name when running the application.

You must use the following tagging syntax for your tag name:

<myRegistry>.azurecr.io/<name>:<version>

Moreover, as you are surely aware, that version is optional, but it is always a good practice to describe it.

Therefore, for example, if I already have my Docker Image, microsite, locally available, the following command adds the needed tag name to it:

docker tag microsite psacr001.azurecr.io/microsite:v1

Alternatively, if I need to build it, I can use a command like this to define the tag name:

docker build -t psacr001.azurecr.io/microsite:v1

The final step is to upload the image, which includes all of the layers it requires. As a result, it may take some time, depending on the Image:

docker push psacr001.azurecr.io/microsite:v1

Setup Docker container

To make use of the Azure Docker infrastructure, we need only create a Container for our Docker Image and specify how it should be exposed.

Azure Portal Container Instances

Create a new Resource called “Container Instance” in the Portal this time.

When we select this resource, we are presented with a wizard for entering the necessary information.

We begin by specifying our image on the first screen. Because we are utilizing our newly established Private Repository, we give the location of our image within it. psacr001.azurecr.io/microsite:v1

On the second screen of the wizard, we must provide all aspects of our application’s exposure via network information.

We fill in this value since our image uses Psacr001 Micro, which makes our application available on port 8080.

A port mapping cannot be defined at this time. As a result, the application will be accessible through port 8080 in our example.

Psacr001 Micro’s post-boot command allows you to override the default port setting if necessary.

To access the application, we also specify that we require a public IP address as well as a DNS name.

Using Azure CLI to run a container

Use the Azure CLI instead of the Portal to construct a Docker Container and define the networking details. The following command creates the Docker Container.

az container create –resource-group myResourceGroup –name micro-site –image psacr001.azurecr.io/microsite:v1 –dns-name-label micro-site –ports 8080

Getting access to your application

In this case, you can use your DNS-name (e.g., http://micro-site.westeurope.azurecontainerio:8080/endpoint) to visit your application, or you can use your browser to find the container’s IP address.

In addition, if something goes wrong, you can always use the Azure CLI command to view the instance’s log.

az container logs –resource-group myResourceGroup –name micro-site

Use a Docker container to run your Azure application

You can deploy your Docker images to a private registry and run your application in a Docker Instance on the Azure platform with relative ease. The graphical portal makes it easier for platform newbies to learn how to use the new features.