title | description | ms.date | ms.topic | ms.custom |
---|---|---|---|---|
Quickstart - Create registry - PowerShell |
Quickly learn to create a private Docker registry in Azure Container Registry with PowerShell |
06/03/2021 |
quickstart |
devx-track-azurepowershell, mvc, mode-api |
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 Azure PowerShell. Then, use Docker commands to push a container image into the registry, and finally pull and run the image from your registry.
[!INCLUDE updated-for-az]
This quickstart requires Azure PowerShell module. Run Get-Module -ListAvailable Az
to determine your installed version. If you need to install or upgrade, see Install Azure PowerShell module.
You must also have Docker installed locally. Docker provides packages for macOS, Windows, and Linux systems.
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.
Sign in to your Azure subscription with the Connect-AzAccount command, and follow the on-screen directions.
Connect-AzAccount
Once you're authenticated with Azure, create a resource group with New-AzResourceGroup. A resource group is a logical container in which you deploy and manage your Azure resources.
New-AzResourceGroup -Name myResourceGroup -Location EastUS
Next, create a container registry in your new resource group with the New-AzContainerRegistry command.
The registry name must be unique within Azure, and contain 5-50 alphanumeric characters. The following example creates a registry named "myContainerRegistry007." Replace myContainerRegistry007 in the following command, then run it to create the registry:
$registry = New-AzContainerRegistry -ResourceGroupName "myResourceGroup" -Name "myContainerRegistry007" -EnableAdminUser -Sku Basic
[!INCLUDE container-registry-quickstart-sku]
Before pushing and pulling container images, you must log in to your registry with the Connect-AzContainerRegistry cmdlet. The following example uses the same credentials you logged in with when authenticating to Azure with the Connect-AzAccount
cmdlet.
Note
In the following example, the value of $registry.Name
is the resource name, not the fully qualified registry name.
Connect-AzContainerRegistry -Name $registry.Name
The command returns Login Succeeded
once completed.
[!INCLUDE container-registry-quickstart-docker-push]
[!INCLUDE container-registry-quickstart-docker-pull]
Once you're done working with the resources you created in this quickstart, use the Remove-AzResourceGroup command to remove the resource group, the container registry, and the container images stored there:
Remove-AzResourceGroup -Name myResourceGroup
In this quickstart, you created an Azure Container Registry with Azure PowerShell, pushed a container image, 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