Container Instances
Introduction
Section titled “Introduction”Azure Container Instances is a serverless container service that lets you run Docker containers on demand without managing any underlying virtual machines or orchestration infrastructure. Each deployment unit is called a container group and can host one or more containers that share a network and lifecycle. Container Instances is well-suited for short-lived tasks, CI workloads, and event-driven processing. For more information, see About Azure Container Instances.
LocalStack for Azure provides a local environment for building and testing applications that use Azure Container Instances. The supported APIs are available on our API Coverage section, which provides information on the extent of Container Instances’ integration with LocalStack.
Getting started
Section titled “Getting started”This guide is designed for users new to Container Instances and assumes basic knowledge of the Azure CLI and our azlocal wrapper script.
Launch LocalStack using your preferred method. For more information, see Introduction to LocalStack for Azure. Once the container is running, enable Azure CLI interception by running:
azlocal start-interceptionThis command points the az CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
To revert this configuration, run:
azlocal stop-interceptionThis reconfigures the az CLI to send commands to the official Azure management REST API.
Create a resource group
Section titled “Create a resource group”Create a resource group that will contain your Container Instances resources:
az group create \ --name rg-aci-demo \ --location westeurope{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-aci-demo", "location": "eastus", "name": "rg-aci-demo", "properties": { "provisioningState": "Succeeded" }, "type": "Microsoft.Resources/resourceGroups"}Create a container group
Section titled “Create a container group”Create a container group with a single container, a public IP address, and port 80 exposed:
az container create \ --name mycontainer \ --resource-group rg-aci-demo \ --image mcr.microsoft.com/cbl-mariner/base/core:2.0 \ --cpu 1 --memory 1 \ --ports 80 \ --ip-address Public \ --restart-policy Never \ --command-line "/bin/sh -c 'echo hello && sleep 3600'"{ "containers": [ { "command": [ "/bin/sh", "-c", "echo hello && sleep 3600" ], "environmentVariables": [], "image": "mcr.microsoft.com/cbl-mariner/base/core:2.0", "instanceView": { "currentState": { "detailStatus": "", "exitCode": null, "finishTime": null, "startTime": "2026-04-15T13:05:28+00:00", "state": "Running" }, "events": [], "previousState": null, "restartCount": 0 }, "name": "mycontainer", "ports": [ { "port": 80, "protocol": null } ], "resources": { "limits": null, "requests": { "cpu": 1.0, "memoryInGb": 1.0 } } } ], "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-aci-demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer", "instanceView": { "events": [], "state": "Running" }, "ipAddress": { "ip": "10.0.0.1", "ports": [ { "port": 80, "protocol": "TCP" } ], "type": "Public" }, "location": "eastus", "name": "mycontainer", "osType": "Linux", "provisioningState": "Succeeded", "restartPolicy": "Never", "sku": "Standard", "type": "Microsoft.ContainerInstance/containerGroups" ...}Show and list container groups
Section titled “Show and list container groups”Retrieve the full details of the container group to inspect its current state:
az container show \ --name mycontainer \ --resource-group rg-aci-demo{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-aci-demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer", "instanceView": { "events": [], "state": "Running" }, "ipAddress": { "ip": "10.0.0.1", "ports": [ { "port": 80, "protocol": "TCP" } ], "type": "Public" }, "location": "eastus", "name": "mycontainer", "osType": "Linux", "provisioningState": "Succeeded", "restartPolicy": "Never", "type": "Microsoft.ContainerInstance/containerGroups" ...}List all container groups within the resource group to see a summary of each one:
az container list \ --resource-group rg-aci-demo[ { "ipAddress": { "ip": "10.0.0.1", "ports": [ { "port": 80, "protocol": "TCP" } ], "type": "Public" }, "location": "eastus", "name": "mycontainer", "osType": "Linux", "provisioningState": "Succeeded" }]Retrieve container logs
Section titled “Retrieve container logs”Fetch the standard output from a running container to verify it started correctly:
az container logs \ --name mycontainer \ --resource-group rg-aci-demo \ --container-name mycontainerhelloStop, start, and restart
Section titled “Stop, start, and restart”Stop a running container group to release its compute resources without deleting the group:
az container stop \ --name mycontainer \ --resource-group rg-aci-demoVerify that the container group state has changed to Stopped:
az container show \ --name mycontainer \ --resource-group rg-aci-demo \ --query "{name:name, provisioningState:provisioningState, instanceView:instanceView}"{ "instanceView": { "events": [], "state": "Stopped" }, "name": "mycontainer", "provisioningState": "Succeeded"}Start the container group again to resume the containers from their stopped state:
az container start \ --name mycontainer \ --resource-group rg-aci-demoVerify the container group is running again:
az container show \ --name mycontainer \ --resource-group rg-aci-demo \ --query "{name:name, provisioningState:provisioningState, instanceView:instanceView}"{ "instanceView": { "events": [], "state": "Running" }, "name": "mycontainer", "provisioningState": "Succeeded"}Restart all containers in the group without re-creating the group itself:
az container restart \ --name mycontainer \ --resource-group rg-aci-demoConfirm the group is running after the restart:
az container show \ --name mycontainer \ --resource-group rg-aci-demo \ --query "{name:name, provisioningState:provisioningState, instanceView:instanceView}"{ "instanceView": { "events": [], "state": "Running" }, "name": "mycontainer", "provisioningState": "Succeeded"}Delete and verify
Section titled “Delete and verify”Delete the container group to remove all associated containers and Docker resources from the emulator:
az container delete \ --name mycontainer \ --resource-group rg-aci-demo \ --yesVerify the resource group is now empty:
az container list \ --resource-group rg-aci-demo[]Features
Section titled “Features”- Real Docker execution: Container groups are backed by real Docker containers running on the local Docker engine.
- Full container group lifecycle: Stop, start, and restart operations are supported.
- Container logs: Logs are streamed directly from the Docker container and returned via the
containers__list_logsAPI. - Volume types: Both
emptyDirandsecretvolume types are implemented using bind mounts from temporary directories on the host. - Private registries: Image registry credentials passed via
--registry-login-server,--registry-username, and--registry-passwordare used to pull images from private registries. - Init containers: Init containers run sequentially before main containers and must exit with code 0 for group creation to succeed.
Limitations
Section titled “Limitations”- No interactive exec sessions:
az container execand thecontainers__execute_commandAPI return a stub WebSocket URI but do not provide a real terminal session. - No interactive attach:
containers__attachreturns a stub WebSocket URI and does not stream container output interactively. - Linux containers only: Windows containers are not supported.
- No VNet integration: Subnet-based networking is not emulated; all container groups are assigned an IP address from a local address pool.
- No
az container update: Tag updates must be performed viaaz rest PATCH.
Samples
Section titled “Samples”The following samples demonstrate how to use Azure Container Instances with LocalStack for Azure:
API Coverage
Section titled “API Coverage”| Operation ▲ | Implemented ▼ |
|---|