Running Containers with Azure Container Instances
This lesson explains container groups, the settings used to create a container instance, and the service's storage options and limits.
Learning outcomes
After completing this lesson, you will be able to:
- Describe container groups.
- Describe the main settings for creating a container instance, including restart policies.
- Identify the limitations of Container Instances.
Container groups
The top-level resource in ACI is the container group, a collection of containers scheduled on the same host machine. Containers in a group share a lifecycle, resources, a local network (they reach each other on localhost with different ports) and storage volumes, similar to a Kubernetes pod. A group with one container is the most common case; multi-container groups, used for patterns such as an application with a logging sidecar, are supported on Linux only and are deployed with a YAML file or an ARM template, not the portal's basic form.
The following diagram compares the restart policies of Azure Container Instances for a short nightly script.

Container groups
Creating a container instance in the portal
The Create container instance wizard sets the resource group, name, region, availability zone (optional), image source (quickstart images, Azure Container Registry, or another registry such as Docker Hub with credentials if private), image, OS type (Linux or Windows) and size (CPU cores and memory in GB). The Networking tab chooses Public (a public IP with an optional DNS name label, giving label.region.azurecontainer.io), Private (deployed into a delegated VNet subnet) or None, and the ports to expose. The Advanced tab sets the restart policy, environment variables (including secure values that are not displayed), a command override and a managed identity.
| Restart policy | Behaviour | Use for |
|---|---|---|
| Always (default) | Containers are always restarted | Long-running services such as web servers |
| OnFailure | Restarted only if the process exits with an error | Tasks that must finish successfully |
| Never | Run once and stop | Run-once jobs, builds, scripts |
Which restart policy?
Storage, logs and limits
Container file systems are temporary, so persistent data uses mounted volumes: an Azure Files share (Linux containers), emptyDir, a Git repo or a secret volume. Container logs and events are viewed on the instance's Containers page or with az container logs and az container attach, and az container exec opens a shell. ACI does not provide autoscaling, load balancing across groups or rolling upgrades; for those, use Azure Container Apps or AKS. ACI is ideal for simple applications, build agents, task automation and bursting from AKS through virtual nodes.
Living with ACI's limits
A nightly data job
A containerized script processes the previous day's files each night, writing results to a shared location, and takes about 20 minutes. It must not restart after completing successfully, but should retry if it crashes. The team wants the lowest cost and no servers to manage. What should you configure?
Run it in Azure Container Instances with restart policy OnFailure, mount an Azure Files share for the results, and start the container group each night from automation such as a Logic App. Billing is per second only while it runs. Always would restart the script after it finishes, and Never would not retry after a crash.
Which operating system supports multi-container groups in Container Instances?
Show answer
Linux only.
Exam Tips
Remember for the exam
- A container group's containers share lifecycle, network and volumes; multi-container groups are Linux only.
- Restart policies: Always (default), OnFailure, Never.
- Persistent storage: mount an Azure Files share.
- ACI has no autoscaling; use Container Apps for scaling services.