Deploy a container in Azure Container Instances (ACI)

Introduction

What is this project about?
We are deploying a Docker container to Azure Container Instances (ACI), a service that allows us to run containers without managing virtual machines. This approach is fully managed and lets us scale as needed.

Why is this project useful in the real world?

Scalability: We can scale containers automatically based on demand.

Cost-Effectiveness: Pay only for what we use, and there is a free tier/trial for getting started without additional credits.

Simplicity: Azure Container Instances require minimal configuration and no virtual machine overhead.

Prerequisites

Required Tools & Accounts

Azure Account
Create a Free Tier or Free Trial Account on Azure. This typically doesn’t require any up-front credits for small-scale tests.

Azure CLI (Installed Locally)
Ensures we can run commands to manage Azure resources from our terminal.

Docker Installed (Optional)
If we plan to build or test containers locally, Docker is useful but not strictly required if we already have a container image.

Azure Subscription with Owner or Contributor Permissions
We must have sufficient permissions to create resource groups and container instances.

Enable Necessary Azure Services
Azure Container Registry (optional if hosting your own image in ACR).
Azure Container Instances must be available in your chosen region.

Make sure all these prerequisites are in place before proceeding.


Step-by-Step Implementation

Below, each step includes both Console (GUI) and Terminal (CLI) methods, along with an explanation of what each CLI command does. Follow the method that suits you best or use both for practice.

Step 1: Sign into Azure

Console (GUI)

Go to Azure Portal.

Sign in with your Azure account.

You will land on the dashboard.

Terminal (CLI)

Open your preferred terminal (PowerShell, Command Prompt, or any shell).

Run:

What does it do?

  • This command opens a browser window for you to sign into your Azure account. Once authenticated, it stores your credentials locally so you can manage Azure resources via CLI.

Step 2: Create a Resource Group

A resource group is a logical container for all your Azure resources.

Console (GUI)

In the left-hand menu, select Resource groups.

Click Create.

Choose your Subscription, enter a Resource group name (e.g., myACIResourceGroup), and select a Region (e.g., East US).

Click Review + Create and then Create.

Terminal (CLI)

Run:

What does it do?
az group create creates a new Azure resource group.
--name specifies the name of the resource group.
--location specifies the Azure region (e.g., eastus).


You should see a JSON output confirming the creation of the resource group.

Step 3: Prepare or Identify Your Container Image

We can either use a public container image (e.g., from Docker Hub) or one from Azure Container Registry.

Console (GUI)

  • Using a Public Image (e.g., from Docker Hub)
    Note down the Image Name. Example: nginx:latest or microsoft/aci-helloworld:latest.

No specific screenshot needed here unless you want to show your chosen image in Docker Hub.

Terminal (CLI)

  • (Optional) Pull and Test Locally
  • What does it do?
    docker pull downloads the image locally.
    docker run starts a container from the image.
    -p 8080:80 maps port 8080 of your machine to port 80 in the container.


This step is optional if you already trust the container image you are using.

Step 4: Deploy the Container to Azure Container Instances

Console (GUI)

In the Azure Portal, navigate to Container instances in the left menu.

Click Create.

Under Basics:
Subscription: Select your free/trial subscription.
Resource group: Select myACIResourceGroup.
Container name: For example, myacicontainer.
Region: East US.

Under Image type, choose Quickstart images if you want a sample, or Public container registry if you are using a Docker Hub image.
For a Docker Hub image, enter the name, e.g., nginx:latest.

Networking: You can choose to make it publicly accessible on a new public IP address.

Click Review + Create > Create.

Terminal (CLI)

Run:

What does it do?
az container create creates a new container instance in Azure.
--resource-group specifies the resource group to contain the instance.
--name is the container instance name.
--image is the container image to deploy (e.g., nginx:latest).
--ports 80 opens port 80.
--dns-name-label provides a publicly accessible DNS prefix. $RANDOM ensures uniqueness for the DNS label.
--location specifies the Azure region.


You should see JSON output confirming the container creation.

Step 5: Monitor Deployment Status

Console (GUI)

Wait for the deployment to complete (you will see a notification in the Azure Portal).

Once the deployment finishes, navigate to Container instances > myacicontainer.

In the Overview tab, you should see the Status as Running.

Terminal (CLI)

Run:

What does it do?
az container show retrieves the details of your container instance.
--resource-group and --name specify which instance.
--out table displays the result in a readable table format.


Look for the provisioningState and ipAddress fields. Succeeded indicates successful provisioning.

Verifying and Testing the Project

  • Open the Public URL:
    If you set a DNS label (e.g., myacicontainer-12345.eastus.azurecontainer.io), navigate to it in your browser. You should see the default Nginx page or your app’s page.
  • Check Logs (Optional):
  • What does it do?
    az container logs fetches the real-time logs from your container to help verify if it started successfully.
  • Scale-Up or Update (Optional):
    Adjust container size, environment variables, or scale settings from the Container instances page if needed.

Common Issues and Troubleshooting

  • Container Fails to Start
    Check if the image name is correct or publicly accessible.
    Review logs via az container logs or the Logs section in the portal.
  • Invalid Resource Group or Region
    Make sure the specified resource group name matches what you created.
    Verify the region is available for Azure Container Instances.
  • DNS Label Conflicts
    If using --dns-name-label, ensure the chosen label is unique.
    Append a random string (like $RANDOM) to avoid conflicts.
  • Insufficient Permissions
    Ensure you have at least Contributor rights on the subscription or resource group.

Conclusion

We have successfully deployed a container to Azure Container Instances (ACI) without incurring costs, thanks to the Azure free tier/trial. We learned how to create resource groups, configure a container instance using both the console and the CLI, and verify that the container is running. We also covered how to diagnose common issues by reviewing logs and deployment outputs.

This project demonstrates that managing containers on Azure can be simple yet powerful. We hope this guide helps you confidently deploy and test containerized applications on ACI.

What is Cloud Computing ?

Cloud computing delivers computing resources (servers, storage, databases, networking, and software) over the internet, allowing businesses to scale and pay only for what they use, eliminating the need for physical infrastructure.


  • AWS: The most popular cloud platform, offering scalable compute, storage, AI/ML, and networking services.
  • Azure: A strong enterprise cloud with hybrid capabilities and deep Microsoft product integration.
  • Google Cloud (GCP): Known for data analytics, machine learning, and open-source support.