Skip to content

Latest commit

 

History

History
108 lines (72 loc) · 4.47 KB

container-registry-get-started-powershell.md

File metadata and controls

108 lines (72 loc) · 4.47 KB
title description services documentationcenter author manager editor ms.service ms.devlang ms.topic ms.tgt_pltfrm ms.workload ms.date ms.author
Quickstart - Create a private Docker registry in Azure with PowerShell
Quickly learn to create a private Docker container registry with PowerShell.
container-registry
neilpeterson
timlt
tysonn
container-registry
na
article
na
na
10/08/2017
nepeters

Create an Azure Container Registry using PowerShell

Azure Container Registry is a managed Docker container registry service used for storing private Docker container images. This guide details creating an Azure Container Registry instance using PowerShell.

This quickstart requires the Azure PowerShell module version 3.6 or later. Run Get-Module -ListAvailable AzureRM to find the version. If you need to install or upgrade, see Install Azure PowerShell module.

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

Log in to Azure

Log in to your Azure subscription with the Login-AzureRmAccount command and follow the on-screen directions.

Login-AzureRmAccount

Create resource group

Create an Azure resource group with New-AzureRmResourceGroup. A resource group is a logical container into which Azure resources are deployed and managed.

New-AzureRmResourceGroup -Name myResourceGroup -Location EastUS

Create a container registry

Create an ACR instance using the New-AzureRMContainerRegistry command.

The name of the registry must be unique. In the following example myContainerRegistry007 is used. Update this to a unique value.

$registry = New-AzureRMContainerRegistry -ResourceGroupName "myResourceGroup" -Name "myContainerRegistry007" -EnableAdminUser -Sku Basic

Log in to ACR

Before pushing and pulling container images, you must log in to the ACR instance. First, use the Get-AzureRmContainerRegistryCredential command to get the admin credentials for the ACR instance.

$creds = Get-AzureRmContainerRegistryCredential -Registry $registry

Next, use the docker login command to log in to the ACR instance.

docker login $registry.LoginServer -u $creds.Username -p $creds.Password

The command returns a 'Login Succeeded' message once completed.

Push image to ACR

To push an image to an Azure Container registry, you must first have an image. If needed, run the following command to pull a pre-created image from Docker Hub.

docker pull microsoft/aci-helloworld

The image must be tagged with the ACR login server name. Run the Get-AzureRmContainerRegistry command to return the login server name of the ACR instance.

Get-AzureRmContainerRegistry | Select Loginserver

Tag the image using the docker tag command. Replace acrLoginServer with the login server name of your ACR instance.

docker tag microsoft/aci-helloworld <acrLoginServer>/aci-helloworld:v1

Finally, use docker push to push the images to the ACR instance. Replace acrLoginServer with the login server name of your ACR instance.

docker push <acrLoginServer>/aci-helloworld:v1

Clean up resources

When no longer needed, you can use the Remove-AzureRmResourceGroup command to remove the resource group, ACR instance, and all container images.

Remove-AzureRmResourceGroup -Name myResourceGroup

Next steps

In this quickstart, you created an Azure Container Registry with the Azure CLI. If you would like to use Azure Container Registry with Azure Container Instances, continue to the Azure Container Instances tutorial.

[!div class="nextstepaction"] Azure Container Instances tutorial