AZURE CLOUD 101
Azure DevOps — Azure Container Registry
Azure container registry is a service provided by Azure Cloud that stores and distributes container images.
Azure container registry format:
[loginUrl]/[namespace]/[artifact:][tag]
loginUrl — The fully qualified name of the registry host.
namespace — logical grouping of related images or artifacts
artifact — name of image
tag — version
#### Example how to push image in ACR> sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
flask-sample v 51c3779414dd 4 hours ago 459MB> sudo docker tag flask-sample:v1 xyz.azurecr.io/flask-sample:v1> sudo docker login xyz.azurecr.io
** password can be fetched from ACR details page in Azure cloud > sudo docker push xyz.azurecr.io/flask-sample:v1
Sample Azure DevOps pipeline to build and push in ACR-
#file to support
trigger:
- master
resources:
- repo: self
variables:
tags: $(Build.BuildId)
stages:
- stage: Build
displayName: Build image for flask website
jobs:
- job: Build
displayName: Build Job for Flask Website
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
inputs:
containerRegistry: 'regcontainer'
command: 'login'
- task: Docker@2
inputs:
containerRegistry: 'regcontainer'
repository: 'flask-sample'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
So what I am doing above ?
I am using OOTB docker task to build and push the docker image in ACR. Main parameters which are required are -
containerRegistry — Service connection (add in project settings)
repository — Repository Name
tags — Default value $(Build.BuildId)
***Please note When using buildAndPush
command in Docker task, the arguments
are ignored. If you want specific argument to pass then you can split build and push into two separate steps.
