Push Docker Image to Azure Container Registry

Introduction

Azure Container Registry is a centralized hub for managing container images and artifacts, seamlessly integrating with various environments such as Azure App Service, Kubernetes Service, Red Hat OpenShift, and more. By default, the 'latest' tag is automatically assigned when pushing images to Azure Container Registry repositories. With continuous image pushes, the registry replaces the tags on older images with the 'latest' tag for the most recent version.

Effective repository space management is crucial, and this blog will guide you on the best practices for cleaning and organizing your container images. Specifically, you will learn to retain only the latest image while removing all other outdated images.

Push Local Image to the ACR

In this blog, you will learn how to push the docker image to the Azure container registry.

Before pushing the image, it's necessary to log in to the Azure Container Registry (ACR). Execute the following command to initiate the login process.

az acr login --name <server-name>

In my case

az acr login --name travelcontainerregistry

Docker login

Tag the image

Before pushing the local image containing an ASP.NET Core application to Azure Container Registry (ACR), it's essential to assign a tag. Employ the following command to tag the image:

docker tag <localImageName> <login-server>/<repository-name:tagname>

My local images

In my case,

Docker local images

I have used the below command.

docker tag dockersampleapp travelcontainerregistry.azurecr.io/dockersampleapp:v1

Push the image

Use the below command to push the local image to ACR.

docker push travelcontainerregistry.azurecr.io/dockersampleapp:v1

Push images

Local docker image successfully pushed to ACR.

Repository created

The new repository was created in the container registry with the image name 'dockersampleapp' and tag 'v1'.

Summary

We have seen how to push the local docker image into the Azure container registry. We will see more about the Azure container registry in my future blogs.