az container

(PREVIEW) Manage Azure Container Instances.

Commands

az container create Create a container group.
az container delete Delete a container group.
az container list List container groups.
az container logs Examine the logs for a container group.
az container show Get the details of a container group.

az container create

Create a container group.

az container create --image
--name
--resource-group
[--azure-file-volume-account-key]
[--azure-file-volume-account-name]
[--azure-file-volume-mount-path]
[--azure-file-volume-share-name]
[--command-line]
[--cpu]
[--environment-variables]
[--ip-address {Public}]
[--location]
[--memory]
[--os-type {Linux, Windows}]
[--ports]
[--registry-login-server]
[--registry-password]
[--registry-username]
[--restart-policy {Always, Never, OnFailure}]

Examples

Create a container in a container group with 1 core and 1Gb of memory.

az container create -g MyResourceGroup --name myalpine --image alpine:latest --cpu 1 --memory 1

Create a container in a container group that runs Windows, with 2 cores and 3.5Gb of memory.

az container create -g MyResourceGroup --name mywinapp --image winappimage:latest --os-type Windows --cpu 2 --memory 3.5

Create a container in a container group with public IP address and ports.

az container create -g MyResourceGroup --name myalpine --image alpine:latest --ip-address public --ports 80 443

Create a container in a container group that invokes a script upon start.

az container create -g MyResourceGroup --name myalpine --image alpine:latest --command-line "/bin/sh -c '/path to/myscript.sh'"

Create a container in a container group that runs a command and stop the container afterwards.

az container create -g MyResourceGroup --name myalpine --image alpine:latest --command-line "echo hello" --restart-policy Never

Create a container in a container group with environment variables.

az container create -g MyResourceGroup --name myalpine --image alpine:latest -e key1=value1 key2=value2

Create a container in a container group using container image from Azure Container Registry.

az container create -g MyResourceGroup --name myalpine --image myAcrRegistry.azurecr.io/alpine:latest --registry-password password

Create a container in a container group using container image from another private container image registry.

az container create -g MyResourceGroup --name myapp --image myimage:latest --cpu 1 --memory 1.5 --registry-login-server myregistry.com --registry-username username --registry-password password

Create a container in a container group that mounts an Azure File share as volume.

az container create -g MyResourceGroup --name myapp --image alpine:latest --command-line "cat /mnt/azfile/myfile" --azure-file-volume-share-name myshare --azure-file-volume-account-name mystorageaccount --azure-file-volume-account-key mystoragekey --azure-file-volume-mount-path /mnt/azfile

Required Parameters

--image

The container image name.

--name -n

The name of the container group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--azure-file-volume-account-key

The storage account access key used to access the Azure File share.

--azure-file-volume-account-name

The name of the storage account that contains the Azure File share.

--azure-file-volume-mount-path

The path within the container where the volume should be mounted. Must not contain colon (:).

--azure-file-volume-share-name

The name of the Azure File share to be mounted as a volume.

--command-line

The command line to run when the container is started, e.g. '/bin/bash -c myscript.sh'.

--cpu

The required number of CPU cores of the containers.

default value: 1
--environment-variables -e

A list of environment variable for the container. Space separated values in 'key=value' format.

--ip-address

The IP address type of the container group.

accepted values: Public
--location -l

Location. You can configure the default location using az configure --defaults location=<location>.

--memory

The required memory of the containers in GB.

default value: 1.5
--os-type

The OS type of the containers.

accepted values: Linux, Windows
default value: Linux
--ports

The ports to open.

--registry-login-server

The container image registry login server.

--registry-password

The password to log in container image registry server.

--registry-username

The username to log in container image registry server.

--restart-policy

Restart policy for all containers within the container group.

accepted values: Always, Never, OnFailure
default value: Always

az container delete

Delete a container group.

az container delete --name
--resource-group
[--yes]

Required Parameters

--name -n

The name of the container group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--yes -y

Do not prompt for confirmation.

az container list

List container groups.

az container list [--resource-group]

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az container logs

Examine the logs for a container group.

az container logs --name
--resource-group
[--container-name]

Required Parameters

--name -n

The name of the container group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--container-name

The container name to tail the logs.

az container show

Get the details of a container group.

az container show --name
--resource-group

Required Parameters

--name -n

The name of the container group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.