Thursday, September 30, 2021

How to upload Docker Images into Azure Container Registry using Azure Pipelines | Automate Docker builds using Azure Pipelines | Upload Docker Image into Azure Container Registry (ACR)

We will learn how to build Docker image and upload the Docker images into Azure Container Registry(ACR) using Azure Build pipelines.

Pre-requistes:

1. ACR is setup in Azure cloud. (see below for the steps)
2. Already created Azure DevOps dashboard in 
3. Dockerfile created along with the application source code

How to Create Azure Container Registry?

First Create Resource Group

Make sure you are login to Azure portal first.

az login

Execute below command to create a resource group in Azure portal.

az group create --name myResourceGroup --location southcentralus

Run the below command to create your own private container registry using Azure Container Registry (ACR).

az acr create --resource-group myResourceGroup --name myacrrepo31 --sku Standard --location southcentralus

You can login to Azure portal to see the ACR repo.


How to create a Azure Build Pipeline

1. Login into your Azure DevOps dashboard
2. Click on Pipelines.

3. Click on New Pipeline

4. Click on use the classic editor
Enter your repo name and branch name where you have stored your source code along with Dockerfile

Click on Continue. Now choose the template by typing Docker, Select Docker container and Apply.
 

Now pipeline is created with two tasks already. Now we need to customize it.

Let's modify Build an image task. Choose azure subscription and enter Microsoft credentials and select ACR repo from the drop down


Select Push an image task and select Azure subscription and select ACR repo from the drop down


Add a task for Copying YAML file, enter the Kubernetes deployment YAML file

Add Publish artifact task


Now click Save + Queue and run to start Building the pipeline



Once the build is completed, you should be able to see the Docker images under 
Services --> Repositories


Please watch the above steps in YouTube Channel:

No comments:

Post a Comment

Create Freestyle job in Jenkins | How to create build job in Jenkins to automate Java build and deployment of WAR into Tomcat | Bitbucket Jenkins Integration

Jenkins is popular open source Continuous integration tool. It was written entirely in Java. Jenkins is a self-contained automation server u...