You are configuring a continuous integration pipeline in GitHub Actions to build and push a container image to an Azure Container Registry (ACR) named contosoacr.azurecr.io. The runner does not have the Azure CLI installed, but has the Docker CLI installed. You have created an Azure Active Directory (Azure AD) service principal with the AcrPush role.
You need to authenticate the Docker CLI on the runner to contosoacr.azurecr.io using the service principal credentials.
Which command should you execute in the pipeline runner?
- Aaz acr login --name contosoacr --username <clientId> --password <clientSecret>
- Becho <clientSecret> | docker login contosoacr --username <clientId> --password-stdin
- echo <clientSecret> | docker login contosoacr.azurecr.io --username <clientId> --password-stdinCevap
- DConfigure a system-assigned managed identity for the GitHub-hosted runner, and run az acr login --name contosoacr without credentials.
Cevap
Run the command: echo <clientSecret> | docker login contosoacr.azurecr.io --username <clientId> --password-stdin
To authenticate the Docker CLI with an Azure Container Registry using a service principal when the Azure CLI is unavailable, you must use the standard docker login command. The username must be the service principal's Client ID, the password must be the Client Secret, and the target registry must be specified by its repository login server domain name.
Adım Adım Çözüm
Anahtar Kavram
Authenticating to Azure Container Registry using Docker CLI and service principal credentials.