Task 03 - Create an Azure Container Registry (ACR) instance and push the app container to ACR
Introduction
Azure Container Registry (ACR) is a managed, private Docker registry service provided by Microsoft Azure. It allows you to store and manage container images and artifacts in a secure and scalable manner.
Description
In this task, you’ll create an Azure Container Registry instance.
The key steps are as follows:
- Create an Azure Container Registry instance.
- Sign in to ACR and push the app container that you created in the previous task to ACR.
Success Criteria
- You’ve pushed the app container to ACR.
Learning Resources
Solution
Expand this section to view the solution
-
Enter the following command at the Terminal window prompt and then select Enter.
az login
-
Enter the following command at the Terminal window prompt and then select Enter. This command generates a unique name for the ACR instance.
$ACR_NAME = "contosoacr$(Get-Random -Minimum 100000 -Maximum 999999)" Write-Host -ForegroundColor Green "ACR name is: " $ACR_NAME
-
Enter the following command at the Terminal window prompt and then select Enter. This command creates an ACR instance.
az acr create --resource-group "ContosoHotel" --name "$ACR_NAME" --sku Basic --admin-enabled true
Record the ACR name. You’ll need to supply the ACR name again later in the lab.
-
Enter the following command at the Terminal window prompt and then select Enter. This command signs you in to the ACR instance.
az acr login --name "$ACR_NAME"
-
When a message displays stating that you’ve logged into Microsoft Azure, close the web page and return to Visual Studio Code.
You may see an error message stating the Azure could not connect to the registry login server. This error usually indicates that even though the container registry instance is provisioned, there’s still some configuration happening. Wait a few minutes and run the command again.
-
Enter the following command at the Terminal window prompt and then select Enter. This command creates a Docker tag for the app.
docker tag "pycontosohotel:v1.0.0" "$ACR_NAME.azurecr.io/pycontosohotel:v1.0.0"
-
Enter the following command at the Terminal window prompt and then select Enter. This command pushes the app container to ACR.
docker push "$ACR_NAME.azurecr.io/pycontosohotel:v1.0.0"
It may take 1-2 minutes to push the app container to ACR.
-
Leave Visual Studio Code open. You’ll use the tool in the next task.