/azure-container

Deploying an Image to Azure Registry

Azure Container

Container technology is growing popularly among developers these days and we wonder why. Containerization of software application allows building and deloying mordern applicaiton that is scalable

According to Microsoft a container is a standard package of software that bundles an application'c code together with the related configuration files and libraries, and with the dependencies required for the app to run. This allows developers and IT pros to deploy applications seamlessly across environements.

Advantages of Containerization

  • Solve configurations error and delpoyment error that arizes from changing your software configuration or environment. A software applicaition, its dependencies, its os and its configuration are packaged together.

Walkthrough of Deploying a Containerized Web Server on Azure Registry

  1. Download a sample react application code base with docker file from here. I downloaded the react-nginx project

  2. Bulid and Run the docker image with the command below utilizing docker compose

    docker compose up -d
    
  3. Go to http://localhost to test the application. Take note of the port mapping. image-map

  4. You can stop the container with the command

    docker container stop <container_id>
    
  5. Then remove the container with the command

    docker container rm <container_id>
    
  6. List the images using the command

        docker images 
    

image-map

  1. Now you can go to the Azure portal. Create a resource group.
  2. Search for Container Registry. Create a container registry. I created a container registry called azcontainer7
  3. In your local machine, login to azure portal using the command
    az login
  1. Login to the azure container registry

az acr login --name <name-of-registry>
  1. Tag the local image with the registy url and repository name using the command below
docker tag <image-name> <registry-url>/<repository-name>
  1. Push the image to the repository using the command
 docker push <registry-url>/<repository-name>
  1. Below is an image of the commands I ran to push to the container registry

container-registry

  1. Now go to you resource group and create a new container app resource container-app

  2. I ran into an issue of Azure unable to retrieve the image in Azure Container Registry because admin credentials are disabled

admin-acr-issue

  1. Go back to the ACR dashboard, Click on properties in the settings tab and enable Admin user admin-acr-fix

  2. Now we can create the container app using the image in ACR

  3. overview-app

  4. If you run into a broken link, check if ingress target port matches the container app port