Azure For Containers: Part 1 — Container Registry
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
- Docker Registry 2.0
- Pull Mechanism
- QuickStart
- Prerequisites
- Create an account on Azure Container Registry
- Log In to Container Registry
- 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
Pull Mechanism
- Registry endpoint, often referred to as the login URL, used for authentication and content discovery.
A command likedocker pull contoso.azurecr.io/hello-world
makes a REST request which authenticates and negotiates the layers which represent the requested artifact. - Data endpoints serve blobs representing content layers.
2. Quickstart
Prerequisites:
- Azure Account
- Azure CLI (version 2.0.55+)
- Docker(version 1.6+)
- Helm (version 3+)
Create an Azure Container Registry (ACR)
Using Portal
- Go to Azure Portal and sign in to your account.
- Go to Create a resource > Containers > Container Registry.
- Fill in all the required fields and click on Review+Create.
- When the Deployment succeeds, select the container registry in the portal and note the login server address.
Using CLI
- 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.
- Sign to Azure CLI
az login
2. Generate Docker Credentials for Container Registry
az acr login --name acr-cluephant
ACR for Docker
- 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.