liveBook · Manning

Acr build

As explained in Learn Docker in a Month of Lunches, Second Edition

az acr build is an Azure CLI command that submits a Docker image build to Azure Container Registry's managed build service.

When Docker is unavailable or you want Azure to handle the build, acr build sends a local Dockerfile and source folder to Azure compute. Azure builds the image and stores the result in your Azure Container Registry (ACR). section 14.2

cd ch14/exercises/hello-cloud-web
# build locally:
docker build -t diamol/ch14-web --quiet .
# and build the same image in ACR:
az acr build --image diamol/ch14-web --registry ${ACR_NAME} .
# you may get a TasksOperationsNotAllowed error if you're using
# free credits - if you do just import the image instead:
az acr import -n $ACR_NAME --source `
ghcr.io/diamol2e/ch14-hello-cloud-web -t diamol/ch14-web
# print the tag list for the new image repository:
az acr repository show-tags -n ${ACR_NAME} --repository diamol/ch14-web

Run the same build locally and in ACR, then inspect the repository tags to verify that Azure created the image. section 14.2

Use the command with these practical considerations:

  • Run it from the folder containing the Dockerfile and application source, passing the image name and registry. section 14.2
  • Expect a clean build agent for each task; large base images may need downloading every time. section 14.2
  • Consider it for parallel CI/CD builds, but weigh Azure’s simplicity against staying with the standard Docker workflow. section 14.2

Build and verify a website image

From ch14/exercises/hello-cloud-web, run `az acr build --image diamol/ch14-web --registry ${ACR_NAME} .`, then list tags with `az acr repository show-tags -n ${ACR_NAME} --repository diamol/ch14-web`. section 14.2

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains the local-folder workflow, clean-agent caching limitation, performance comparison, and CI/CD trade-off.
Examples
Builds a simple Alpine-based website image locally and in ACR, then checks its repository tags.
What it assumes
Assumes an ACR registry and a local folder containing a Dockerfile and source code.
What you can do after
Build it from scratch in Azure without requiring Docker on the local machine.
How it connects
Connects Docker build, Azure Container Registry, Docker Hub, and CI/CD pipelines.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.