LinuxCommandLibrary

az-container

Manage Azure Container Instances

TLDR

Create a container in a container group

$ az container create [[-g|--resource-group]] [resource_group] [[-n|--name]] [name] --image [image_name] [[-os|--os-type]] [windows|linux] --cpu [number_of_CPU_cores] --memory [memory_in_GB]
copy

Execute a command from within a running container of a container group
$ az container exec [[-g|--resource-group]] [resource_group] [[-n|--name]] [container_group_name] --exec-command "[command]"
copy

Examine the logs of a container in a container group
$ az container logs [[-n|--name]] [name] [[-g|--resource-group]] [resource_group]
copy

Get the details of a container group
$ az container show [[-n|--name]] [name] [[-g|--resource-group]] [resource_group]
copy

Start all containers in a container group
$ az container start [[-n|--name]] [name] [[-g|--resource-group]] [resource_group]
copy

Stop all containers in a container group
$ az container stop [[-n|--name]] [name] [[-g|--resource-group]] [resource_group]
copy

Delete a container group
$ az container delete [[-n|--name]] [name] [[-g|--resource-group]] [resource_group]
copy

SYNOPSIS

az container { attach | create | delete | describe | exec | list | logs | port-forward | restart | show | update | wait } [options]

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. Default: json.

--query
    JMESPath query string. See http://jmespath.org/ for details.

--subscription
    Name or ID of subscription. Use az account set -s NAME_OR_ID for default.

--verbose
    Increase logging verbosity. Use --debug for full logs.

DESCRIPTION

The az container command is part of the Azure Command-Line Interface (Azure CLI), a cross-platform tool for managing Azure resources. It provides a command group for Azure Container Instances (ACI), enabling users to deploy and manage Docker containers directly on Azure infrastructure without provisioning virtual machines or orchestrators like Kubernetes.

ACI offers serverless container execution, ideal for burst workloads, CI/CD pipelines, and simple apps. With az container, you can create container groups (collections of one or more containers), list running instances, view logs, execute commands inside containers, restart groups, and more.

Key features include GPU support, multi-container groups sharing resources, and public/private IP assignments. It integrates seamlessly with other Azure services like Azure Container Registry (ACR) for image pulls and Azure Files for storage.

Usage requires Azure CLI installation (az --version to check), login via az login, and an active subscription. Commands often require --resource-group and --name for targeting specific instances. Output formats include JSON, table, and TSV for scripting.

CAVEATS

Requires Azure CLI 2.0+ and az login. Not all subcommands support every option; check az container <subcommand> --help. ACI has regional availability, billing per second, and 90-day log retention limits.

COMMON SUBCOMMANDS

az container create: Deploy new group.
az container list: List groups in resource group.
az container logs: Fetch logs.

PREREQUISITES

Install Azure CLI: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash. Login: az login.

HISTORY

Introduced with Azure CLI 2.0 in 2017 alongside ACI preview. Became generally available in 2018 with subcommands like create and logs. Evolved with ACI features: GPU support (2019), confidential computing (2021), and vCPU/memory optimizations.

SEE ALSO

az acr(1), az aks(1), docker(1)

Copied to clipboard