Azure Container Registry is a private registry for hosting container images, which is hosted for you on Azure platform. You can use it to store your private Docker images for all types of container deployments. Azure Container Registry integrates well with orchestrators hosted in Azure Container Service, including Docker Swarm, DC/OS, and Kubernetes. It is fully compatible with pen source Docker Registry v2.
Such registries are mostly used in following scenarios:
- Store and manage container images across all types of Azure deployments
- Use standard open source command line interface (CLI) tools
- Simplify registry access with Azure Active Directory
- Maintain Windows and Linux container images in a single Docker registry
Once the container registry is created you will see following:
To test repository create an ASP.NET Core WebApi project with docker support.
If you don't know how to do that, please take a look here.
After the project is created, you will see following:
If you run this project (F5), navigate to URL http://localhost:port/api/values
and you will get some result. This means your API is working locally.
After you have build the project docker compose several times go to command prompt and execute
You will notice following image:
webapi.docker dev 2d504b16f8f1 7 hours ago 299MB
This image is created by Visual Studio build process. To deploy this image Azure Registry go to WebApi.Docker project, right-mouse click and publish the project directly to registry. Go to azure portal and notice published repository.
After few deployments, take a look in you command prompt for images created after each deployment:
Plese note, that too many deployments migth vaste your drive space :). You should clean unnedded images.
Now, if you like you can run created container locally from any of deployed images. But note please don't use image with label 'dev'. That one will not run as it should.
Use following command to run image:
docker run -it -p 5000:80 damir.azurecr.io/webapi.docker:20180101081410
And you should see following:
Open browser and navigate to: http://localhost:5000/api/values/
As next, let's deploy the image from command prompt using azure CLI. Remember, in previous step we have deployed image by using Visual Studio.
To do this, you first have to install ACR Docker Credential Helper as an admin.
iex ([System.Text.Encoding]::UTF8.GetString((Invoke-WebRequest -Uri https://aka.ms/acr/installaad/win).Content))
This tool allows you to sign-in to the Azure Container Registry service using you Azure Active Directory (AAD) credentials.
Now you can login to Azure Contaner Registry with following command:
az acr login --name damir
Name damir is a host nae of my registry. Do not use here FQDN like damir.azurecr.io.
Before you can publish the image, you have to create a tag as in a case of docker hub.
docker tag webapi.docker:latest damir.azurecr.io/mywebapi:v2
and finally push the new tagged image to Azure Container Registry:
docker push damir.azurecr.io/mywebapi:v2
Finally, fo to azure portal in your ACR, scroll down and lookup repositories on the left side. This is the place where you can find published repository.