简体   繁体   English

Docker 通过服务原理登录到 Azure 容器注册表

[英]Docker login to Azure Container Registry by Service Principle

I've created a service principle with AcrPush role assigned.我创建了一个分配了 AcrPush 角色的服务原则。 But when I access the container registry from docker it ask me user name and password.但是当我从 docker 访问容器注册表时,它会询问我用户名和密码。 I've never set the user name and password, how can I configure the docker to user the service principle?我从来没有设置过用户名和密码,如何配置docker来使用服务原理?

You do not have to set the username and password as it is already there in the container registry.您不必设置用户名和密码,因为它已经存在于容器注册表中。 In the container registry, you can enable the admin mode, and that is where you get your credentials from.在容器注册表中,您可以启用管理员模式,这就是您获取凭据的地方。 在此处输入图像描述

docker login myregistry.azurecr.io

Enter the username and password from the portal and it should work.从门户输入用户名和密码,它应该可以工作。

With service principal if properly created, you can do the following:如果正确创建了服务主体,您可以执行以下操作:

docker login myregistry.azurecr.io --username $SP_APP_ID --password $SP_PASSWD

For your issue, you use the service principal for the ACR with the role AcrPush to push the images.对于您的问题,您使用具有AcrPush角色的 ACR 的服务主体来推送图像。 The username and the password are that appId and password of the service principal, but you need to take care that the password is only displayed once when the service principal is created.用户名和密码是服务主体的 appId 和密码,但您需要注意密码仅在创建服务主体时显示一次。 If you forget the password, you need to reset it.如果忘记密码,则需要重新设置。 So the docker login would be like this:所以 docker 登录将是这样的:

docker login youracr.azurecr.io -u app_id -p app_password

In addition to the answer from @kgalic, you can also do the following: You didn't specify as to where you're executing the docker login command, but assumingyou have access to the Azure CLI and appropriate credentials, you can log into your azure container registry via az acr login --name <acrName> .除了@kgalic 的回答之外,您还可以执行以下操作:您没有指定执行docker登录命令的位置,但假设您可以访问 Azure CLI 和适当的凭据,您可以登录到您的azure 容器注册表通过az acr login --name <acrName> This will flow the ACR credentials down to docker so that you don't need to execute a separate docker login这会将 ACR 凭据向下传递到 docker,因此您无需执行单独的docker login

See the following for more information: https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication有关详细信息,请参阅以下内容: https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 容器注册表`docker login` 不起作用 - Azure Container Registry `docker login` does not work 无法 docker 登录到 azure 容器注册表 - Unable to docker login into azure container registry Azure 应用服务私有容器注册表登录问题 - Azure app service private container registry login problem Azure 容器 - 无法登录私有注册表“从 docker 注册表收到错误响应” - Azure Container - can not login to private registry “Error response received from the docker registry” 登录到 Azure 管道中的 Azure 容器注册表 - Login to Azure Container Registry in Azure Pipeline 如何从 GitLab 容器注册表将 Docker 容器部署到 Azure 应用服务 - How to deploy a Docker container to Azure App Service from GitLab container registry Azure 应用服务无法启动 w/ Azure 容器注册表拉取 - Docker 容器 - 找不到文件 - 与 Docker 集线器一起使用 - Azure App Service Fails to Start w/ Azure Container Registry Pull - Docker Container - Can not Find File - Works with Docker Hub Powershell + Azure 应用服务 + Azure 容器注册表 - Powershell + Azure App Service + Azure Container Registry 从Azure容器注册表部署Docker映像 - Deploying a Docker Image from Azure Container Registry Docker 推送到 Azure Container Registry:拒绝访问 - Docker Push to Azure Container Registry: Access Denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM