DEVELOPER BLOG

HOME > DEVELOPER BLOG > 【Introduction to Azure】Run Container Registry container images on Container Instance

【Introduction to Azure】Run Container Registry container images on Container Instance

1. Introduction

Hello! We are a writer team from Definer Inc. Azure Container Registry and Azure Container Instances are two powerful services provided by Microsoft Azure for managing containerized applications. Azure Container Registry serves as a private repository to store and manage Docker container images securely, while Azure Container Instances offer a serverless solution to run containers without the need to manage underlying infrastructure. In this issue, you are wondering how to run container images from Azure Container Registry on Azure Container Instance. Let's take a look at the actual screens and resources to explain in detail.

2. Purpose/Use Cases

The purpose of running container registry container images on container instances is to simplify the deployment and management of containerized applications. By combining these two services, developers can easily deploy container images stored in the Azure Container Registry onto Azure Container Instances, benefiting from the agility and scalability of serverless container execution. Key Benefits and Purpose:
  1. Seamless Deployment and Execution
  2. Serverless Container Execution
  3. Private and Secure Container Registry
  4. Isolation and Resource Efficiency
  5. Quick Prototyping and Development
  6. Application Flexibility and Versatility
  7. Integration with Other Azure Services

3. Setting up Azure Container Registry

First, we will set up the registry and Docker images. (1) Create Azure Container Registry: To get started, log in to the Azure console and navigate to the "Container Registry" service. Click on "Create" and provide the required details, such as the subscription and resource group information. This will create a new Azure Container Registry, which will serve as a private repository to store Docker container images securely.   (2) Preparation of Container Image: Next, you need to prepare the container image that you want to push to the Azure Container Registry. In this example, we'll use an nginx container image. If you already have the nginx container image locally, you can skip this step. Otherwise, you can obtain the nginx container image by running the command "docker pull nginx" in your terminal or command prompt. (3) Tag the Container Image and Prepare for Push: Before pushing the container image to the Azure Container Registry, you need to tag it with the registry's login server address. To do this, use the "docker tag" command. The format for tagging is "docker tag <source_image> <registry_login_server>/<repository>:<tag>". Replace the placeholders with your actual image, login server, repository name, and desired tag. (4) Login to Azure Container Registry: To push images to the Azure Container Registry, you need to log in to the registry using Docker. The user and password information required for login can be found on the "Access Key" tab of the Container Registry details screen. If the administrator user is disabled, make sure to enable it first. (5) Push the Container Image to Azure Container Registry: Once you are logged in to the Azure Container Registry, you can push the nginx container image to the registry using the "docker push" command. The format is "docker push <registry_login_server>/<repository>:<tag>". This will upload the container image to your Azure Container Registry.
## Download nginx image locally and run
sudo docker run nginx

## Tagged with nginx image
sudo docker tag nginx testforruncontainer.azurecr.io/nginx:1.0


## Login to Azure Container Registry
sudo docker login -u testForRunContainer -p ${password} testforruncontainer.azurecr.io


## Push to Azure Container Registry
sudo docker push testforruncontainer.azurecr.io/nginx:1.0                

4. Container execution in Azure Container Instance

Next, we will run the container in Azure Container Instance.   (1) Container Startup: After pushing the nginx container image to the Azure Container Registry, the next step is to run the container in Azure Container Instance. To do this, log in to the Azure console and access the "Container Instance" service. Click on "Create" and provide the required details, such as the subscription and resource group information. For the "Image Source," select "Azure Container Registry" and choose the registry and image you just created (nginx in this case). This tells Azure that the container image will be sourced from the Azure Container Registry. Next, select the network configuration. In this example, select "Public" to allow the Azure Container Instance to be accessible via a public IP address. This is useful for quickly testing the container's functionality.     (2) Confirmation of Container Startup: After configuring the Azure Container Instance settings, click on "Create" to start the container. Azure will then create and deploy the container instance using the specified container image from the Azure Container Registry. Once the container instance is up and running, you can view its details in the Azure Container Instance dashboard. In the "Summary" section of the detail screen, you will find the public IP address of the container instance. By clicking on the public IP address, you will be able to access the running nginx container's web server. This will display the nginx welcome screen or any other content that is served by the nginx container.

5. Cited/Referenced Articles

6. About the proprietary solution "PrismScaler"

・PrismScaler is a web service that enables the construction of multi-cloud infrastructures such as AWS, Azure, and GCP in just three steps, without requiring development and operation. ・PrismScaler is a web service that enables multi-cloud infrastructure construction such as AWS, Azure, GCP, etc. in just 3 steps without development and operation. ・The solution is designed for a wide range of usage scenarios such as cloud infrastructure construction/cloud migration, cloud maintenance and operation, and cost optimization, and can easily realize more than several hundred high-quality general-purpose cloud infrastructures by appropriately combining IaaS and PaaS.  

7. Contact us

This article provides useful introductory information free of charge. For consultation and inquiries, please contact "Definer Inc".

8. Regarding Definer

・Definer Inc. provides one-stop solutions from upstream to downstream of IT. ・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition/design development/implementation, and maintenance and operation. ・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition, design development, implementation, maintenance, and operation. ・PrismScaler is a high-quality, rapid, "auto-configuration," "auto-monitoring," "problem detection," and "configuration visualization" for multi-cloud/IT infrastructure such as AWS, Azure, and GCP.