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
