Skip to content

Commit 3d544ff

Browse files
docs(azure): add Container Instances article
1 parent 8949d4c commit 3d544ff

1 file changed

Lines changed: 354 additions & 0 deletions

File tree

Lines changed: 354 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,354 @@
1+
---
2+
title: "Container Instances"
3+
description: Get started with Azure Container Instances on LocalStack
4+
template: doc
5+
---
6+
7+
import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage";
8+
9+
## Introduction
10+
11+
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.
12+
Each deployment unit is called a container group and can host one or more containers that share a network and lifecycle.
13+
Container Instances is well-suited for short-lived tasks, CI workloads, and event-driven processing. For more information, see [About Azure Container Instances](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-overview).
14+
15+
LocalStack for Azure provides a local environment for building and testing applications that use Azure Container Instances.
16+
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Container Instances' integration with LocalStack.
17+
18+
## Getting started
19+
20+
This guide is designed for users new to Container Instances and assumes basic knowledge of the Azure CLI and our `azlocal` wrapper script.
21+
22+
Launch LocalStack using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/). Once the container is running, enable Azure CLI interception by running:
23+
24+
```bash
25+
azlocal start-interception
26+
```
27+
28+
This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
29+
To revert this configuration, run:
30+
31+
```bash
32+
azlocal stop-interception
33+
```
34+
35+
This reconfigures the `az` CLI to send commands to the official Azure management REST API.
36+
37+
### Create a resource group
38+
39+
Create a resource group that will contain your Container Instances resources:
40+
41+
```bash
42+
az group create \
43+
--name rg-aci-demo \
44+
--location eastus
45+
```
46+
47+
```bash title="Output"
48+
{
49+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-aci-demo",
50+
"location": "eastus",
51+
"name": "rg-aci-demo",
52+
"properties": {
53+
"provisioningState": "Succeeded"
54+
},
55+
"type": "Microsoft.Resources/resourceGroups"
56+
}
57+
```
58+
59+
### Create a container group
60+
61+
Create a container group with a single container, a public IP address, and port 80 exposed:
62+
63+
```bash
64+
az container create \
65+
--name mycontainer \
66+
--resource-group rg-aci-demo \
67+
--image mcr.microsoft.com/cbl-mariner/base/core:2.0 \
68+
--cpu 1 --memory 1 \
69+
--ports 80 \
70+
--ip-address Public \
71+
--restart-policy Never \
72+
--command-line "/bin/sh -c 'echo hello && sleep 3600'"
73+
```
74+
75+
```bash title="Output"
76+
{
77+
"containers": [
78+
{
79+
"command": [
80+
"/bin/sh",
81+
"-c",
82+
"echo hello && sleep 3600"
83+
],
84+
"environmentVariables": [],
85+
"image": "mcr.microsoft.com/cbl-mariner/base/core:2.0",
86+
"instanceView": {
87+
"currentState": {
88+
"detailStatus": "",
89+
"exitCode": null,
90+
"finishTime": null,
91+
"startTime": "2026-04-15T13:05:28+00:00",
92+
"state": "Running"
93+
},
94+
"events": [],
95+
"previousState": null,
96+
"restartCount": 0
97+
},
98+
"name": "mycontainer",
99+
"ports": [
100+
{
101+
"port": 80,
102+
"protocol": null
103+
}
104+
],
105+
"resources": {
106+
"limits": null,
107+
"requests": {
108+
"cpu": 1.0,
109+
"memoryInGb": 1.0
110+
}
111+
}
112+
}
113+
],
114+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-aci-demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer",
115+
"instanceView": {
116+
"events": [],
117+
"state": "Running"
118+
},
119+
"ipAddress": {
120+
"ip": "10.0.0.1",
121+
"ports": [
122+
{
123+
"port": 80,
124+
"protocol": "TCP"
125+
}
126+
],
127+
"type": "Public"
128+
},
129+
"location": "eastus",
130+
"name": "mycontainer",
131+
"osType": "Linux",
132+
"provisioningState": "Succeeded",
133+
"restartPolicy": "Never",
134+
"sku": "Standard",
135+
"type": "Microsoft.ContainerInstance/containerGroups"
136+
...
137+
}
138+
```
139+
140+
### Show and list container groups
141+
142+
Retrieve the full details of the container group to inspect its current state:
143+
144+
```bash
145+
az container show \
146+
--name mycontainer \
147+
--resource-group rg-aci-demo
148+
```
149+
150+
```bash title="Output"
151+
{
152+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-aci-demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer",
153+
"instanceView": {
154+
"events": [],
155+
"state": "Running"
156+
},
157+
"ipAddress": {
158+
"ip": "10.0.0.1",
159+
"ports": [
160+
{
161+
"port": 80,
162+
"protocol": "TCP"
163+
}
164+
],
165+
"type": "Public"
166+
},
167+
"location": "eastus",
168+
"name": "mycontainer",
169+
"osType": "Linux",
170+
"provisioningState": "Succeeded",
171+
"restartPolicy": "Never",
172+
"type": "Microsoft.ContainerInstance/containerGroups"
173+
...
174+
}
175+
```
176+
177+
List all container groups within the resource group to see a summary of each one:
178+
179+
```bash
180+
az container list \
181+
--resource-group rg-aci-demo
182+
```
183+
184+
```bash title="Output"
185+
[
186+
{
187+
"ipAddress": {
188+
"ip": "10.0.0.1",
189+
"ports": [
190+
{
191+
"port": 80,
192+
"protocol": "TCP"
193+
}
194+
],
195+
"type": "Public"
196+
},
197+
"location": "eastus",
198+
"name": "mycontainer",
199+
"osType": "Linux",
200+
"provisioningState": "Succeeded"
201+
}
202+
]
203+
```
204+
205+
### Retrieve container logs
206+
207+
Fetch the standard output from a running container to verify it started correctly:
208+
209+
```bash
210+
az container logs \
211+
--name mycontainer \
212+
--resource-group rg-aci-demo \
213+
--container-name mycontainer
214+
```
215+
216+
```bash title="Output"
217+
hello
218+
```
219+
220+
### Stop, start, and restart
221+
222+
Stop a running container group to release its compute resources without deleting the group:
223+
224+
```bash
225+
az container stop \
226+
--name mycontainer \
227+
--resource-group rg-aci-demo
228+
```
229+
230+
Verify that the container group state has changed to `Stopped`:
231+
232+
```bash
233+
az container show \
234+
--name mycontainer \
235+
--resource-group rg-aci-demo \
236+
--query "{name:name, provisioningState:provisioningState, instanceView:instanceView}"
237+
```
238+
239+
```bash title="Output"
240+
{
241+
"instanceView": {
242+
"events": [],
243+
"state": "Stopped"
244+
},
245+
"name": "mycontainer",
246+
"provisioningState": "Succeeded"
247+
}
248+
```
249+
250+
Start the container group again to resume the containers from their stopped state:
251+
252+
```bash
253+
az container start \
254+
--name mycontainer \
255+
--resource-group rg-aci-demo
256+
```
257+
258+
Verify the container group is running again:
259+
260+
```bash
261+
az container show \
262+
--name mycontainer \
263+
--resource-group rg-aci-demo \
264+
--query "{name:name, provisioningState:provisioningState, instanceView:instanceView}"
265+
```
266+
267+
```bash title="Output"
268+
{
269+
"instanceView": {
270+
"events": [],
271+
"state": "Running"
272+
},
273+
"name": "mycontainer",
274+
"provisioningState": "Succeeded"
275+
}
276+
```
277+
278+
Restart all containers in the group without re-creating the group itself:
279+
280+
```bash
281+
az container restart \
282+
--name mycontainer \
283+
--resource-group rg-aci-demo
284+
```
285+
286+
Confirm the group is running after the restart:
287+
288+
```bash
289+
az container show \
290+
--name mycontainer \
291+
--resource-group rg-aci-demo \
292+
--query "{name:name, provisioningState:provisioningState, instanceView:instanceView}"
293+
```
294+
295+
```bash title="Output"
296+
{
297+
"instanceView": {
298+
"events": [],
299+
"state": "Running"
300+
},
301+
"name": "mycontainer",
302+
"provisioningState": "Succeeded"
303+
}
304+
```
305+
306+
### Delete and verify
307+
308+
Delete the container group to remove all associated containers and Docker resources from the emulator:
309+
310+
```bash
311+
az container delete \
312+
--name mycontainer \
313+
--resource-group rg-aci-demo \
314+
--yes
315+
```
316+
317+
Verify the resource group is now empty:
318+
319+
```bash
320+
az container list \
321+
--resource-group rg-aci-demo
322+
```
323+
324+
```bash title="Output"
325+
[]
326+
```
327+
328+
## Features
329+
330+
LocalStack for Azure emulates Azure Container Instances using real Docker containers running on the local Docker engine.
331+
The full container group lifecycle is supported, including stop, start, and restart operations.
332+
Container logs are streamed directly from the Docker container and returned via the `containers__list_logs` API.
333+
Both `emptyDir` and `secret` volume types are implemented using bind mounts from temporary directories on the host.
334+
Private registries are supported by passing image registry credentials in the `--registry-login-server`, `--registry-username`, and `--registry-password` flags on `az container create`.
335+
Init containers run sequentially before main containers and must exit with code 0 for the group creation to succeed.
336+
337+
## Limitations
338+
339+
Interactive exec sessions (`az container exec`) are not supported.
340+
The `containers__execute_command` API returns a stub WebSocket URI but does not provide a real terminal session.
341+
Similarly, `containers__attach` returns a stub WebSocket URI and does not stream container output interactively.
342+
Windows containers are not supported; only Linux containers can be created.
343+
VNet integration and subnet-based networking are not emulated; all container groups are assigned an IP address from a local address pool.
344+
The `az container update` CLI command is not available; tag updates must be performed via `az rest PATCH`.
345+
346+
## Samples
347+
348+
The following samples demonstrate how to use Azure Container Instances with LocalStack for Azure:
349+
350+
- [Azure Container Instances quickstart](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-quickstart)
351+
352+
## API Coverage
353+
354+
<AzureFeatureCoverage service="Microsoft.ContainerInstance" client:load />

0 commit comments

Comments
 (0)