Skip to content

Commit 4acabb1

Browse files
Azure Docs: Azure Container Registry (#598)
Co-authored-by: Brian Rinaldi <brian.rinaldi@gmail.com>
1 parent 3468621 commit 4acabb1

1 file changed

Lines changed: 227 additions & 1 deletion

File tree

Lines changed: 227 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,237 @@
11
---
22
title: "Container Registry"
3-
description: API coverage for Microsoft.ContainerRegistry in LocalStack for Azure.
3+
description: Get started with Azure Container Registry on LocalStack
44
template: doc
55
---
66

77
import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage";
88

9+
## Introduction
10+
11+
Azure Container Registry (ACR) is a managed, private OCI-compatible registry for storing container images and Helm charts.
12+
It integrates natively with Azure Kubernetes Service, Azure Container Instances, and Azure App Service to streamline container-based application deployments.
13+
ACR is commonly used to build, store, and manage container images as part of a continuous integration and deployment pipeline. For more information, see [What is Azure Container Registry?](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-intro).
14+
15+
LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Container Registry.
16+
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Container Registry's integration with LocalStack.
17+
18+
## Getting started
19+
20+
This guide walks you through creating a registry, logging in with Docker, pushing an image, and listing repositories.
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 to hold all resources created in this guide:
40+
41+
```bash
42+
az group create --name rg-acr-demo --location westeurope
43+
```
44+
45+
```bash title="Output"
46+
{
47+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-acr-demo",
48+
"location": "westeurope",
49+
"name": "rg-acr-demo",
50+
"properties": { "provisioningState": "Succeeded" },
51+
"type": "Microsoft.Resources/resourceGroups"
52+
}
53+
```
54+
55+
### Create a container registry
56+
57+
Create a Basic-tier Azure Container Registry (Azure also offers Standard and Premium; limits differ by tier, as described in [Azure Container Registry SKU features and limits](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-skus)):
58+
59+
```bash
60+
az acr create \
61+
--name myacrdemo \
62+
--resource-group rg-acr-demo \
63+
--sku Basic \
64+
--admin-enabled true
65+
```
66+
67+
```bash title="Output"
68+
{
69+
"adminUserEnabled": true,
70+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-acr-demo/providers/Microsoft.ContainerRegistry/registries/myacrdemo",
71+
"location": "westeurope",
72+
"loginServer": "myacrdemo.azurecr.azure.localhost.localstack.cloud:4566",
73+
"name": "myacrdemo",
74+
"provisioningState": "Succeeded",
75+
"resourceGroup": "rg-acr-demo",
76+
"sku": { "name": "Basic", "tier": "Basic" },
77+
"type": "Microsoft.ContainerRegistry/registries"
78+
...
79+
}
80+
```
81+
82+
### Log in with Docker
83+
84+
Authenticate the local Docker daemon to the registry using the Azure CLI:
85+
86+
```bash
87+
az acr login --name myacrdemo
88+
```
89+
90+
With Azure, `az acr login` is the documented way to authenticate Docker to your registry using your signed-in Microsoft Entra identity ([Push your first image to your Azure container registry using the Docker CLI](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-docker-cli?tabs=azure-cli); for other auth options see [Authenticate with an Azure container registry](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication)). The emulator does not reproduce the full Azure identity flow, so the CLI may print an informational warning before confirming `Login Succeeded`. That is expected for LocalStack.
91+
92+
### Build and push an image
93+
94+
Create a minimal `Dockerfile` for the demo image:
95+
96+
```bash
97+
cat > Dockerfile <<'EOF'
98+
FROM alpine:latest
99+
CMD ["echo", "Hello from LocalStack ACR!"]
100+
EOF
101+
```
102+
103+
Capture the registry login server returned by the emulator, then build and push the image using that address:
104+
105+
```bash
106+
LOGIN_SERVER=$(az acr show --name myacrdemo --resource-group rg-acr-demo --query loginServer -o tsv)
107+
docker build -t $LOGIN_SERVER/hello:v1 .
108+
docker push $LOGIN_SERVER/hello:v1
109+
```
110+
111+
Alternatively build directly within the emulated registry:
112+
113+
```bash
114+
az acr build \
115+
--image hello:v1 \
116+
--registry myacrdemo \
117+
.
118+
```
119+
120+
### Pull an image
121+
122+
Pull the image back from the registry to confirm it was pushed correctly:
123+
124+
```bash
125+
docker pull $LOGIN_SERVER/hello:v1
126+
```
127+
128+
### List repositories
129+
130+
List all image repositories stored in the registry:
131+
132+
```bash
133+
az acr repository list --name myacrdemo
134+
```
135+
136+
```bash title="Output"
137+
[
138+
"hello"
139+
]
140+
```
141+
142+
### Check name availability
143+
144+
Check registry name availability against the management API. The following example assumes you already created `myacrdemo` above, so the response matches a name that is not available:
145+
146+
```bash
147+
az acr check-name --name myacrdemo
148+
```
149+
150+
```bash title="Output"
151+
{
152+
"message": "The registry myacrdemo is already in use.",
153+
"nameAvailable": false,
154+
"reason": "AlreadyExists"
155+
}
156+
```
157+
158+
### Update registry settings
159+
160+
Disable the registry admin account (`az acr update` is the same command Azure documents for changing registry settings; see [`az acr update`](https://learn.microsoft.com/en-us/cli/azure/acr#az-acr-update)):
161+
162+
```bash
163+
az acr update --name myacrdemo --resource-group rg-acr-demo --admin-enabled false
164+
```
165+
166+
```bash title="Output"
167+
{
168+
"adminUserEnabled": false,
169+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-acr-demo/providers/Microsoft.ContainerRegistry/registries/myacrdemo",
170+
"loginServer": "myacrdemo.azurecr.azure.localhost.localstack.cloud:4566",
171+
"name": "myacrdemo",
172+
"provisioningState": "Succeeded",
173+
"resourceGroup": "rg-acr-demo",
174+
"sku": { "name": "Basic", "tier": "Basic" },
175+
"type": "Microsoft.ContainerRegistry/registries"
176+
...
177+
}
178+
```
179+
180+
### Show registry usage
181+
182+
Show current storage usage statistics for the registry:
183+
184+
```bash
185+
az acr show-usage --name myacrdemo --resource-group rg-acr-demo
186+
```
187+
188+
```bash title="Output"
189+
{
190+
"value": [
191+
{ "currentValue": 0, "limit": 10737418240, "name": "Size", "unit": "Bytes" },
192+
{ "currentValue": 0, "limit": 2, "name": "Webhooks", "unit": "Count" },
193+
{ "currentValue": 0, "limit": 100, "name": "ScopeMaps", "unit": "Count" },
194+
{ "currentValue": 0, "limit": 100, "name": "Tokens", "unit": "Count" }
195+
]
196+
}
197+
```
198+
199+
### Delete and verify
200+
201+
Delete the registry and remove the demo `Dockerfile` created earlier:
202+
203+
```bash
204+
az acr delete --name myacrdemo --resource-group rg-acr-demo --yes
205+
rm -f Dockerfile
206+
```
207+
208+
## Features
209+
210+
- **Full CRUD lifecycle:** Create, read, update, and delete registry resources using the Azure CLI or ARM API.
211+
- **Admin user management:** Enable or disable admin user access and retrieve admin credentials.
212+
- **Name availability check:** Validate registry name uniqueness via `az acr check-name`.
213+
- **Image push and pull:** Push and pull OCI-compliant container images using the standard Docker CLI.
214+
- **In-registry builds:** Build images directly in the emulated registry using `az acr build`.
215+
- **Repository listing:** List repositories and image tags stored in the registry.
216+
- **Registry usage reporting:** Retrieve storage and limit usage via `az acr show-usage`.
217+
- **Registry update:** Modify registry properties such as admin enabled and SKU.
218+
- **Multiple SKUs accepted:** Basic, Standard, and Premium SKU names are accepted (all backed by the same local registry).
219+
220+
## Limitations
221+
222+
- **Geo-replication not supported:** Multi-region registry replication is not emulated.
223+
- **ACR Tasks beyond basic build:** Task scheduling, triggers, and multi-step task workflows are mocked at the ARM level but not executed.
224+
- **Private endpoints for ACR:** Private Link–based network isolation is not supported.
225+
- **Webhook notifications:** Registry webhooks defined via the ARM API are stored but not fired on push events.
226+
- **Content trust and quarantine:** Image signing and quarantine policies are not enforced.
227+
- **Delete is not persisted:** `az acr delete` returns HTTP 200 and exits cleanly, but the registry record is not removed from the in-memory store in the current emulator version.
228+
229+
## Samples
230+
231+
The following sample demonstrates how to use Azure Container Registry with LocalStack for Azure:
232+
233+
- [Azure Container Instances, Key Vault, and Storage](https://github.com/localstack/localstack-azure-samples/blob/main/samples/aci-blob-storage/python/README.md)
234+
9235
## API Coverage
10236
11237
<AzureFeatureCoverage service="Microsoft.ContainerRegistry" client:load />

0 commit comments

Comments
 (0)