You need to upload a locally built container image to a private Azure Container Registry (ACR) named contosoacr. Arrange the following commands in the correct sequence to authenticate your session and push the image to the registry.
- 1`az login`
- 2`az acr login --name contosoacr`
- 3`docker push contosoacr.azurecr.io/myimage:v1`
Answer
The correct sequence of commands is to first run `az login` to authenticate with Azure, then run `az acr login --name contosoacr` to authenticate with the specific registry, and finally run `docker push contosoacr.azurecr.io/myimage:v1` to upload the image.
The correct order requires first authenticating with Azure via `az login` to set up the CLI credentials context. Next, `az acr login --name contosoacr` uses that context to log the Docker daemon into the target registry. Finally, `docker push contosoacr.azurecr.io/myimage:v1` uploads the image now that authentication is successful.
Step-by-Step Solution
Key Concept
To push local container images to a private Azure Container Registry (ACR), you must first authenticate with Azure using `az login`, authenticate the local Docker client to the registry using `az acr login`, and then execute `docker push` with the registry's login server path.