How to build ARM64 docker images with Azure DevOps Pipelines?
Feb 14, 2024
Azure DevOps doesn’t directly support specifying the architecture in the pipeline YAML. However, you can still achieve ARM64 builds in Azure DevOps pipelines through QEMU emulator.
Example:
Build arm64 Image with the help of QEMU and Push to Docker Hub Registry.
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
- name: container_registry
value: test
- name: repository
value: test/test
steps:
- task: CmdLine@2
displayName: 'Install emulator'
inputs:
script: 'sudo apt-get install -y qemu qemu-user-static'
- task: Docker@2
displayName: 'Login'
inputs:
containerRegistry: $(container_registry)
command: 'login'
- task: Docker@2
displayName: 'Build'
inputs:
containerRegistry: $(container_registry)
repository: $(repository)
command: 'build'
arguments: '--platform linux/arm64'
Dockerfile: 'Dockerfile'
tags: 'latest'
- task: Docker@2
displayName: 'Push'
inputs:
containerRegistry: $(container_registry)
repository: $(repository)
command: 'push'
tags: 'latest'