Image by Frauke Feind from Pixabay

Publishing Docker Image to Azure Container Registry

0Shares

In my previous article, I went through the creation of Docker image and running the container and uploading to Docker Hub repository where I have registered for free.

But if your organization is leveraging Microsoft Azure for their cloud technologies, fortunately Microsoft is providing a private registry in the Microsoft Azure Platform called “Azure Container Registry(ACR)“.

ACR is similar to Docker Hub discussed in the previous article that can store private container images and other artifacts and those are privately available only to the account creators either individual or organizational. In this article I am going to discuss on how to push the local image to ACR.

ACR supports Docker CLI. That means you can use same commands to pull, push and run docker images similar to Docker. You can pull and run in your local or you can directly run the image pointing to ACR.

Steps for pushing the image to Azure Container Registry:

Step 1: Login into the Registry.

az acr login --name <registry-name>

Step 2: Push image to the Registry.

docker push <login-server>/<image>

Step 3: Run image from the Registry.

docker run <login-server>/<image>

For this article, I have created a resource group “testcntainergroup” with container registry name “testcntainerregistry” and the login server got created with the name “testcntainerregistry.azurecr.io“.

Figure 1 – Container Registry details

I have to run following commands to login and push are as below (I will be creating cloning a new image with the registry details):

$ docker tag akkiraju/simplehttp:latest testcntainerregistry.azurecr.io/akkiraju/simplehttp
$ az acr login --name testcntainerregistry
Login Succeeded
$ docker push testcntainerregistry.azurecr.io/akkiraju/simplehttp

This time I will run the container with port 9094 and will be running directly pointing to ACR.

$ docker run -it --rm -p 9094:8081 testcntainerregistry.azurecr.io/akkiraju/simplehttp:latest
Figure 2 – Running container with port 9094

References:

https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-docker-cli

0Shares