The Ops Community βš™οΈ

Cover image for Azure Container Instances 🧿 πŸƒ
Kithmini
Kithmini

Posted on

Azure Container Instances 🧿 πŸƒ

Based on the open-source Docker Registry 2.0, Azure Container Registry is a managed Docker registry service. You can create, save, and manage images for all kinds of container deployments using the private, Azure-hosted Container Registry. It can be summed up as a private registry akin to Docker Hub. An open-source registry called Docker Hub allows anyone to upload their images, but it is private and only you may view it.

Without needing to maintain any virtual machines or adopt a higher-level service, Azure Container Instances (ACI) provides the quickest and easiest way to run a container in Azure. Simple applications, task automation, and build jobs are just a few examples of situations where Azure Container Instances (ACI) provides a fantastic option. One advantage of using ACIs is that you may deploy your container image without creating any YAML files or keeping any VMs or other resources up to date. ACI will take care of everything. It distributes storage, networking, and a lot of other things.

The container group is the primary resource in Azure Container Instances. A group of containers that are scheduled to run on the same host machine is known as a container. The lifecycle, resources, local network, and storage volumes of the containers in a container group are all shared.

Create an Azure resource group:

We should build resource groups before creating container instances and container registry because anything we generate afterwards will be in these groups, and if you delete this group and don't want those resources any more, all resources will be gone.

An resource group can be created using the command line:

 az group create --name tutorial --location eastus
Enter fullscreen mode Exit fullscreen mode

Create an Azure container registry:

We should create a variable for the registry name so that we don't have to input it again throughout the course.

$ACR_NAME = "AzureTutorialForVAC"
Enter fullscreen mode Exit fullscreen mode

The command listed below will assist you in building a container registry:

az acr create --resource-group tutorial --name $ACR_NAME --sku Premium
Enter fullscreen mode Exit fullscreen mode

The sku stands for different service levels that Azure offers. The three categories are Basic, Standard, and Premium.

Let’s now create a Docker file in our project so that we can use it to build an image.

FROM nginx:alpine
COPY . /usr/share/nginx/html
Enter fullscreen mode Exit fullscreen mode

Then access your command prompt. Use the command below to log into your Azure container registry so that Azure cli knows which registry to use:

az acr login --name azuretutorialforvac
Enter fullscreen mode Exit fullscreen mode

Since docker hub is open-source, it is usually logged in because we push images there. However, since we are using the private Azure Container Registry, we must sign in to that account. When you visit the Azure Container Registry in the Azure portal, you will see this login server url. Use the following command for this.

 docker login azuretutorialforvac.azurecr.io
Enter fullscreen mode Exit fullscreen mode

Your username and password will be requested. Go to the Azure Portal, choose your container registry, then select Access Keys in the left sidebar. Set the admin-enabled property to true. The credentials will then be displayed to you. To the prompt, copy and paste those. There is yet another technique to accomplish this, and it involves azure cli. You can do that with the aid of the ensuing commands.

  az acr update -n $ACR_NAME --admin-enabled true
  az acr credential show --name $ACR_NAME
Enter fullscreen mode Exit fullscreen mode

After that, you can use the docker build command to create an image. However, one thing to bear in mind is that the loginserverurl/nameforimage format should be used when giving the tag name to the image in the command.

  docker build -t azuretutorialforvac.azurecr.io/img:1 .
Enter fullscreen mode Exit fullscreen mode

Once it is buit push the image to acr.

docker push azuretutorialforvac.azurecr.io/img:1
Enter fullscreen mode Exit fullscreen mode

Once its done you can use the following command to verify.

  az acr repository list --name $ACR_NAME --output table

Enter fullscreen mode Exit fullscreen mode

Latest comments (0)