In this article, Azure Cloud Shell (Azure CLI) is used to deploy and run a container in Azure Container Instances (ACI). ACI allows running and managing containers and applications easily without managing virtual machines. To deploy an image one can use provided images (Linux or Windows from Docker Hub), Azure container registry, or other image registry. After this exercise one will be able to create container resource group, specify container settings, and verify running containerized application in Azure.
Following tasks are performed:
Create resource
Create container
Verify running container
Clean up resources
Create Resource Group
The first step is to create Azure Container Instance resources using the Azure CLI. Azure CLI is a free Bash shell that can be run directly within the Azure portal. It is preinstalled and configured within an account.
Click the Cloud Shell button on the menu bar at the top right side of the Azure portal.

It will launch an interactive shell which can be used to run the steps outlined in this article. Select a Bash environment. To use code editor go to Settings menu in cloud shell toolbar and than select Go to Classic version.

Create Resource Group - Resource group is a logical container used to hold related resources. It includes all resources which are required to manage as a group. az group create command creates a resource group. If a resource group is already created and exists then this step can be omitted and it can be use in next steps.
Syntax:
az group create \
--name <resource-group> \
--location <location>Example:
az group create \
--name myResourceGroup1 \
--location eastus2 eastus2 is location code instead of it one can use their nearest region location.
az account list-locations command gives complete list of available locations.
az account list-locations
az account list-locations --query "[*].name"
az account list-locations --query "[*].name" --out tsv | sortCreate Container
Let’s create container instance using Azure CLI. az container create command is used to create container instance. Command requires a container instance name, resource group name, and Docker container image. In this exercise mcr.microsoft.com/azuredocs/aci-helloworld public image is used. It is a small web application with one static HTML page and developed in Node.js.
To create a container instance run the below command . DNS name is used to expose container to Internet and it must be unique.
az container create \
--resource-group myResourceGroup1 \
--name myContainer1 \
--image mcr.microsoft.com/azuredocs/aci-helloworld \
--ports 80 \
--dns-name-label aci-example1
--location eastus2
--os-type Linux \
--cpu 1 \
--memory 1.5 It will take few minutes to complete the operation process and once it completes successfully one can verify it as mentioned in below section.
Verify running container
Azure CLI
Once container created successfully next task is to verify the container is running properly or not using az container show command as following. It shows the container’s build status.
az container show \
--resource-group myResourceGroup1 \
--name myContainer1 \
--query "{FQDN:ipAddress.fqdn,ProvisioningState:provisioningState}" \
--out table Output: It displays fully qualified domain name (FQDN) of the container along with it’s state.
| FQDN | ProvisioningState |
|---|---|
| aci-example1.eastus2.azurecontainer.io | Succeeded |
Using Browser
One can access container's FQDN from a browser as below. This will be available only if ProvisioningState is Succeeded for the created container.


Join the conversation! Your thoughts help the community grow.