Soru

Zorluk: KolayManage Container Images in Azure Container Registry

You need to build a container image and push it to an Azure Container Registry named `acrdemo` using the Azure CLI. You want to run the build in Azure Container Registry (ACR) without using a local container engine or daemon. The Dockerfile is located in your current local directory. Which two parameters or arguments must you specify in the `az acr build` command?

  1. The --registry parameter (or -r) followed by the registry nameCevap
  2. The path to the source directory, such as a period (.) to represent the current directoryCevap
  3. C
    The --login flag to authenticate the build task against the registry
  4. D
    The --identity parameter to authenticate the build using the workstation's system-assigned managed identity

Cevap

To build an image using Azure Container Registry Tasks from a local directory, you must run the 'az acr build' command and specify the registry name (using the --registry parameter) and the path to the source files (such as the current directory '.').
To run the az acr build command, you must specify the destination registry via the --registry parameter and the source directory path (such as the period representing the current directory). The command sends the source context to the registry, builds the image, and pushes it automatically.

Adım Adım Çözüm

1
Ensure the Azure CLI is logged in and has access to the target Azure Container Registry.
Your active command-line session is authenticated with Azure.
The build command uses the CLI session's context automatically, eliminating the need for a separate login parameter.
2
Identify the target container registry and the directory containing the Dockerfile.
You have the registry name (acrdemo) and the source directory path (e.g., '.').
These two arguments are mandatory inputs for the az acr build command.
3
Construct and run the command: az acr build --registry acrdemo .
The local source context is packaged, sent to the ACR instance, built according to the Dockerfile, and the resulting image is pushed to the registry.
This executes the remote build without requiring a local Docker container engine.

Anahtar Kavram

Azure Container Registry (ACR) Tasks allow developers to offload container image builds to Azure, removing the need for a local Docker installation. The 'az acr build' command requires the target registry name and the source directory context to run.
Bu soruyu puanla