Azure For Containers: Part 1 — Container Registry

Cluephant
Cluephant
Published in
3 min readOct 7, 2020

--

The increase in the demand for highly portable and platform-independent Applications gave rise to a high adoption rate for Docker and container orchestration services and the constant need for efficient deployment of these containers.

Every Cloud Vendor have their fair share of tools and services that can be used to deploy our applications, In this blog, we will focus on Azure.

Without further ado, let us start.

AZURE CONTAINER SERVICES

These below are the services that are used for storing, managing, and orchestration of the containerized applications.

Container Registry

Azure Kubernetes Service (AKS)

Container Instances

App Service

Batch

Service Fabric

Azure Red Hat OpenShift

This is going to be a 7 part series, in which we will have a gentle introduction about each service and how to get started with them.

Today we will cover Azure Container Registry:

  • Architecture
  1. Docker Registry 2.0
  2. Pull Mechanism
  • QuickStart
  1. Prerequisites
  2. Create an account on Azure Container Registry
  3. Log In to Container Registry
  4. ACR for Docker

Azure Container Registry

1. Architecture

Docker Registry 2.0

Azure Container Registry is a private docker registry build on the top of open-source Docker Registry 2.0.

The docker registry in general is a highly scalable server-side application that can be used to store docker images.

This below image explains the Architecture for Docker Registry 2.0

Source: dockercon 15 (Slides Deck)

Pull Mechanism

  1. Registry endpoint, often referred to as the login URL, used for authentication and content discovery.
    A command like docker pull contoso.azurecr.io/hello-world makes a REST request which authenticates and negotiates the layers which represent the requested artifact.
  2. Data endpoints serve blobs representing content layers.
Source: https://azure.microsoft.com/en-us/blog/azure-container-registry-mitigating-data-exfiltration-with-dedicated-data-endpoints

2. Quickstart

Prerequisites:

  1. Azure Account
  2. Azure CLI (version 2.0.55+)
  3. Docker(version 1.6+)
  4. Helm (version 3+)

Create an Azure Container Registry (ACR)

Using Portal

  1. Go to Azure Portal and sign in to your account.
  2. Go to Create a resource > Containers > Container Registry.
  3. Fill in all the required fields and click on Review+Create.
  4. When the Deployment succeeds, select the container registry in the portal and note the login server address.

Using CLI

  1. Log in to Azure CLI
az login

2. Create Azure Resource group

az group create --name Cluephant --location eastus

This will create a resource group named Cluephant in the eastus location.

3. Create ACR

az acr create --resource-group Cluephant \
--name acr-cluephant --sku Basic

This will create container registry named acr-cluephant with Basic tier in the resource group Cluephant.

Log In to Container Registry

Before using any command we need to login to Azure CLI.

  1. Sign to Azure CLI
az login

2. Generate Docker Credentials for Container Registry

az acr login --name acr-cluephant

ACR for Docker

  1. Create a simple docker image using Dockerfile.
#DockerfileFrom alpine:3.12.0
CMD ["echo", "Hello Cluephant"]

2. Build Image

docker build -t cluephant:0.1 .

3. Tagging image for ACR

docker tag {image}:{tag} {login-server}/{namespace}/{image}:{tag}

Example:

docker tag cluephant:0.1 acr-cluephant.azurecr.io/sample/cluephant:0.1

This specifies the Container registry to store your image in sample namespace.

4. Pushing Image to Container Registry

docker push acr-cluephant.azurecr.io/sample/cluephant:0.1

5. In the same way we can pull images from Container Registry

docker pull acr-cluephant.azurecr.io/sample/cluephant:0.1

Pro Tip: We can use ACR as a Registry for Helm Chart along with docker registry with added support for OCI.

In the Second Part of the series, we will talk about Azure Kubernetes Service in depth.

Originally published at https://www.cluephant.com.

If you need any help with DevOps, CloudOps, and DataOps Best Practises, feel free to reach out to us at Cluephant.com.

--

--

Cluephant
Cluephant

Powerful minds solving world’s greatest challenges to create bold solutions. https://cluephant.com