Step by step guild to deploy Docker Images with Azure Container Instance

Mercy AlagbeMercy Alagbe
3 min read

INTRODUCTION

Azure Container Instances enables deployment of Docker containers onto Azure infrastructure without provisioning any virtual machines or adopting a higher-level service. In this tutorial, This article discuss about how to Deploy a Docker image to an Azure Container Instance. Azure Container Instance aka ACI helps you to run your Docker image in Azure. So to deploy the Docker image to Azure, first you need to publish your Docker image to a container registry then you can connect the Container Instance to the registry and deploy the image.

Follow these prerequisites;

  1. Install Azure CLI on your system

  2. Create Azure Account

  3. Download Docker Desktop on your system.

  4. VScode and the necessary extensions are to be installed.

    After these, the following step by step guilds are the next:

    Step1: Simple Dockerfile is to be created

    Step2: Build Docker Image

    Step3: Set up Azure Container Registry (ACR)

    Step4: Push the Docker Image to Azure Container Registry

    Step5: Deploy the Container to Azure Container Instances (ACI).

    Step1: Simple Dockerfile is to be created

    create a new file in same directory, named hostname.sh

    Step2: Build Docker Image

    To build Docker image, use the command:

    docker images to see your container images present.

    ls command to display files and directory content

    docker build . -t image name

    you can also add tag to your image name, and run it using port 8080 by inputting this commands: docker run --rm --name image name -d -p 8080:80 image name:tag , input docker ps , you can curl your localhost by inputting curl localhost 8080 to see it running

    You can also type localhost:8080 in a new tab and check.

    Step3: Set up Azure Container Registry

    1. Navigate to the Azure portal (https://portal.azure.com/).

    2. Search for "Container Registry".

    3. Follow the bellow image to create Azure Container Registry. review and create.

      wait for your deployment to complete and go to resource. Note your login server in the container registry.

      In Container Registry, click Access Keys and enable Admin User.

      Step4: Push the Docker Image to Azure

      you will need the following commands to push your docker image to Azure Container Registry.

      Replace acr, image name, and tag.

  • Step5: Deploy the Container to Azure Container Instances (ACI).

    1. Navigate to the Azure portal (https://portal.azure.com/).

    2. Search for "Container Instance and create".

    3. Follow the bellow image to create Azure Container Instance. Ensure your networking is public, review and create.

      Wait for the deployment to complete and go to resource.

      You can now copy your ip address and open in a new tab to check the host,

      ip address/version/

      ip address/healthz/

      You've created your Docker image, pushed it to Azure Container Registry, and deployed it using Azure Container Instances successfully, Congratulations!

      I hope you will find this article useful, feel free to comment and ask questions, we are ready to answer you. thank you.

0
Subscribe to my newsletter

Read articles from Mercy Alagbe directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mercy Alagbe
Mercy Alagbe

I'm a cloud enthusiast documenting my journey.