Skip to content

Latest commit

 

History

History
152 lines (110 loc) · 6.16 KB

container-registry-get-started-azure-cli.md

File metadata and controls

152 lines (110 loc) · 6.16 KB
title description ms.topic ms.date ms.custom
Quickstart - Create registry - Azure CLI
Quickly learn to create a private Docker container registry with the Azure CLI.
quickstart
06/12/2020
seodec18, H1Hack27Feb2017, mvc, devx-track-azurecli, mode-api

Quickstart: Create a private container registry using the Azure CLI

Azure Container Registry is a private registry service for building, storing, and managing container images and related artifacts. In this quickstart, you create an Azure container registry instance with the Azure CLI. Then, use Docker commands to push a container image into the registry, and finally pull and run the image from your registry.

This quickstart requires that you are running the Azure CLI (version 2.0.55 or later recommended). Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI.

You must also have Docker installed locally. Docker provides packages that easily configure Docker on any macOS, Windows, or Linux system.

Because the Azure Cloud Shell doesn't include all required Docker components (the dockerd daemon), you can't use the Cloud Shell for this quickstart.

Create a resource group

Create a resource group with the az group create command. An Azure resource group is a logical container into which Azure resources are deployed and managed.

The following example creates a resource group named myResourceGroup in the eastus location.

az group create --name myResourceGroup --location eastus

Create a container registry

In this quickstart you create a Basic registry, which is a cost-optimized option for developers learning about Azure Container Registry. For details on available service tiers, see Container registry service tiers.

Create an ACR instance using the az acr create command. The registry name must be unique within Azure, and contain 5-50 alphanumeric characters. In the following example, myContainerRegistry007 is used. Update this to a unique value.

az acr create --resource-group myResourceGroup \
  --name myContainerRegistry007 --sku Basic

When the registry is created, the output is similar to the following:

{
  "adminUserEnabled": false,
  "creationDate": "2019-01-08T22:32:13.175925+00:00",
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myContainerRegistry007",
  "location": "eastus",
  "loginServer": "mycontainerregistry007.azurecr.io",
  "name": "myContainerRegistry007",
  "provisioningState": "Succeeded",
  "resourceGroup": "myResourceGroup",
  "sku": {
    "name": "Basic",
    "tier": "Basic"
  },
  "status": null,
  "storageAccount": null,
  "tags": {},
  "type": "Microsoft.ContainerRegistry/registries"
}

Take note of loginServer in the output, which is the fully qualified registry name (all lowercase). Throughout the rest of this quickstart <registry-name> is a placeholder for the container registry name, and <login-server> is a placeholder for the registry's login server name.

[!INCLUDE container-registry-quickstart-sku]

Log in to registry

Before pushing and pulling container images, you must log in to the registry. To do so, use the az acr login command. Specify only the registry resource name when logging in with the Azure CLI. Don't use the fully qualified login server name.

az acr login --name <registry-name>

Example:

az acr login --name mycontainerregistry

The command returns a Login Succeeded message once completed.

[!INCLUDE container-registry-quickstart-docker-push]

List container images

The following example lists the repositories in your registry:

az acr repository list --name <registry-name> --output table

Output:

Result
----------------
hello-world

The following example lists the tags on the hello-world repository.

az acr repository show-tags --name <registry-name> --repository hello-world --output table

Output:

Result
--------
v1

[!INCLUDE container-registry-quickstart-docker-pull]

Clean up resources

When no longer needed, you can use the az group delete command to remove the resource group, the container registry, and the container images stored there.

az group delete --name myResourceGroup

Next steps

In this quickstart, you created an Azure Container Registry with the Azure CLI, pushed a container image to the registry, and pulled and ran the image from the registry. Continue to the Azure Container Registry tutorials for a deeper look at ACR.

[!div class="nextstepaction"] Azure Container Registry tutorials

[!div class="nextstepaction"] Azure Container Registry Tasks tutorials