LinuxCommandLibrary

az-acr

Manage Azure Container Registry

TLDR

Create a managed container registry

$ az acr create [[-n|--name]] [registry_name] [[-g|--resource-group]] [resource_group] --sku [sku]
copy

Login to a registry
$ az acr login [[-n|--name]] [registry_name]
copy

Tag a local image for ACR
$ docker tag [image_name] [registry_name].azurecr.io/[image_name]:[tag]
copy

Push an image to a registry
$ docker push [registry_name].azurecr.io/[image_name]:[tag]
copy

Pull an image from a registry
$ docker pull [registry_name].azurecr.io/[image_name]:[tag]
copy

Delete an image from a registry
$ az acr repository delete [[-n|--name]] [registry_name] --repository [image_name]:[tag]
copy

Delete a managed container registry
$ az acr delete [[-n|--name]] [registry_name] [[-g|--resource-group]] [resource_group] [[-y|--yes]]
copy

List images within a registry
$ az acr repository list [[-n|--name]] [registry_name] --output table
copy

SYNOPSIS

az acr [subcommand] [--debug] [--help -h] [--only-show-errors] [--output -o table|tsv|json] [--query -q] [--subscription] [--verbose]

PARAMETERS

--debug
    Increase logging verbosity to show all debug logs

--help -h
    Show this help message and exit

--only-show-errors
    Only show errors, suppressing warnings

--output -o
    Output format: json|jsonc|table|tsv|yaml

--query -q
    JMESPath query string to customize output

--subscription
    Name or ID of Azure subscription

--verbose
    Increase logging verbosity

DESCRIPTION

The az acr command group within the Azure Command-Line Interface (CLI) enables management of Azure Container Registry (ACR) resources. ACR provides a secure, private Docker-compatible registry for storing, building, and distributing container images and OCI artifacts.

Key capabilities include creating and deleting registries, listing and updating configurations, managing access via service principals, RBAC roles, or repository-scoped tokens, building images directly with az acr build, importing/exporting images, running ACR Tasks for CI/CD, enabling geo-replication, and integrating with tools like Azure Kubernetes Service (AKS) and GitHub Actions.

Common use cases involve DevOps pipelines on Linux systems, vulnerability scanning with Microsoft Defender for Containers, and Helm chart repositories. Requires Azure CLI v2.0+ installed (pip install azure-cli or package manager) and authentication via az login. Supports output formats like JSON for scripting.

Enhances container workflows by avoiding public registries like Docker Hub for enterprise security.

CAVEATS

Requires Azure CLI installation and az login authentication. Not all subcommands support all options; check az acr [subcommand] --help. Rate limits apply to ACR operations.

KEY SUBCOMMANDS

build, check-name, create, delete, import, list, login-server, repository, run, task, update

EXAMPLES

az acr create --resource-group myRG --name myacr01 --sku Basic
az acr build --registry myacr01 --image hello:v1 .
az acr repository list --name myacr01 --output table

HISTORY

Introduced in Azure CLI 2.0 (2017) with ACR general availability. Evolved with ACR features like Tasks (2018), premium SKUs, and OCI support (2020+). Aligns with Azure's container ecosystem growth.

SEE ALSO

az(1), az login(1), docker(1), podman(1)

Copied to clipboard